Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 327
Andrey Kuzmin Avatar asked Oct 20 '22 10:10

Andrey Kuzmin


1 Answers

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.

like image 152
Alexandre Kirszenberg Avatar answered Oct 22 '22 02:10

Alexandre Kirszenberg