21

Edit: I opened a new issue with Chromium.


Our project uses TypeScript compiled to JavaScript. When debugging automated unit tests in Karma, I want to disable JavaScript source maps and stick to debugging the compiled code.

I know how to do this from the browser settings but the change expires when I close the browser, so I'm looking for a way to disable it programmatically.

Disable source maps in Chrome DevTools

Chrome accepts other flags from the command line (e.g. --no-sandbox). Is there a flag or similar means to disable source maps?

7
  • Based on the Chromium flags list peter.sh/experiments/chromium-command-line-switches it seems there isn't any flags to disable the JavaScript Source map files :( Commented Mar 16, 2018 at 9:47
  • Here is an open issue requesting exactly what we are looking for: bugs.chromium.org/p/chromium/issues/detail?id=534874 Commented Mar 16, 2018 at 9:52
  • The list of command line switches linked above contains a flag called --devtools-flags "Passes command line parameters to the DevTools front-end" Maybe this is used in combination with some other flag? Commented Feb 4, 2019 at 22:27
  • There is a workaround in the reported issue bugs.chromium.org/p/chromium/issues/detail?id=781648#c4 Commented Feb 12, 2019 at 17:39
  • For now, try disabling creation of source maps from your bundler? Commented Feb 12, 2019 at 19:48

1 Answer 1

1

on webpack.config.js

add devtool: false

exports.onCreateWebpackConfig = ({ actions, stage }) => {
  // If production JavaScript and CSS build
  if (stage === 'build-javascript') {
    // Turn off source maps
    actions.setWebpackConfig({
      devtool: false,
    })
  }
};

or

You can pass compiler options inside every loader query string

loadWhatEVer?sourceMap=false
Sign up to request clarification or add additional context in comments.

1 Comment

Ah. Nice idea in general: don't serve source maps when running the tests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.