How to remove webpack:// from sources in the browser

走远了吗. 提交于 2019-12-19 08:53:26

问题


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.


回答1:


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

For the webpack template you are looking 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',

    (...)
  }
}



回答2:


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,
}


来源:https://stackoverflow.com/questions/49096454/how-to-remove-webpack-from-sources-in-the-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!