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

I would like to hide part of my code from showing in chrome dev tools. Is it possible with webpack?

+4
source share
1 answer

I think you could create an identifier loader that filters the source maps for these specific files.

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

Then in the configuration of your web package:

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

You can also manually apply SourceMapDevToolPlugininstead of the configuration parameter devtool. The plugin supports asset matching in the same way as boot loaders.

+4
source

All Articles