How to remove webpack:// from sources in the browser
Asked Answered
D

2

16

I am using this webpack template for a Vue.JS website.

I deployed the app and it works well, but if you go to developer tools > Sources in Chrome, then under webpack:// you can see the components and the whole code. Is there a way to get rid of that? Or is this usual if you use webpack?

Thank you.

Damper answered 4/3, 2018 at 14:26 Comment(4)
Why whould you want to do that?Appearance
I don't think anyone should have the possitbility to see the components, etc.Damper
How are you generating the bundle (the app you deployed)?Appearance
The command is: npm run buildDamper
U
19

That's because webpack generates source maps which show the original source code and structure.

For the webpack template, you should look for the config/index.js file,

and in order to skip the source map generation change productionSourceMap to false:

module.exports = {
  dev: {
    (...)
  },

  build: {
  
    (...)

    productionSourceMap: false,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',

    (...)
  }
}
Underneath answered 4/3, 2018 at 17:54 Comment(0)
S
22

if you are using vue-cli and have a vue.config.js file then you can simply just add it like this

module.exports = {
    productionSourceMap: false,
}
Shiller answered 26/4, 2019 at 13:6 Comment(1)
Lifesaver! 8> Should be as accepted one!Partain
U
19

That's because webpack generates source maps which show the original source code and structure.

For the webpack template, you should look for the config/index.js file,

and in order to skip the source map generation change productionSourceMap to false:

module.exports = {
  dev: {
    (...)
  },

  build: {
  
    (...)

    productionSourceMap: false,
    // https://webpack.js.org/configuration/devtool/#production
    devtool: '#source-map',

    (...)
  }
}
Underneath answered 4/3, 2018 at 17:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.