Is there a command line flag to disable JavaScript source maps for Chrome?
Asked Answered
B

1

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?

Buttonball answered 3/5, 2017 at 4:19 Comment(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 :(Gussiegussman
Here is an open issue requesting exactly what we are looking for: bugs.chromium.org/p/chromium/issues/detail?id=534874Gussiegussman
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?Koffman
There is a workaround in the reported issue bugs.chromium.org/p/chromium/issues/detail?id=781648#c4Concerto
For now, try disabling creation of source maps from your bundler?Kwh
found this link to help you #35002587Dairymaid
@Dairymaid the link is already in the question.Buttonball
T
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
Toreutics answered 18/3, 2019 at 18:57 Comment(1)
Ah. Nice idea in general: don't serve source maps when running the tests.Quadrisect

© 2022 - 2024 — McMap. All rights reserved.