问题
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