Is it possible to disable source maps for certain files in webpack?

≯℡__Kan透↙ 提交于 2019-12-21 16:17:08

问题


I'd like to hide a part of my code from being shown in chrome dev tools. Is it possible with webpack?


回答1:


I guess you could create an identity loader who filters out sourcemaps for these particular files.

// remove-sourcemap.loader.js
module.exports = function(source, map) {
  this.callback(null, source)
};

Then, in your webpack config:

module: {
  loaders: [
    include: [/* list of files (absolute path) for which to remove sourcemaps */],
    loader: 'remove-sourcemap',
  ],
},

You could also manually apply the SourceMapDevToolPlugin instead of using the devtool configuration option. The plugin supports asset matching in the same way loaders do.



来源:https://stackoverflow.com/questions/30476045/is-it-possible-to-disable-source-maps-for-certain-files-in-webpack

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