简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM