Webpack Strip Block
Webpack loader to strip blocks of code marked by special comment tags. Useful for removing code that you don't want in your production webpack bundle (e.g. verbose console warnings, etc).
Example:
In your client js source files:
/* debug:start */console;/* debug:end */var { // The following code will be stripped with our webpack loader /* develblock:start */ if bar instanceof Bar !== true throw 'makeFoo: bar param is required and must be instance of Bar'; /* develblock:end */ // This code would remain return bar baz;}
<!-- develblock:start --> <!-- develblock:end -->
In your webpack config, specify the loader:
var blocks = 'develblock'; if processenvNODE_ENV === 'development' blocks; moduleexports = module: rules: test: /\.js$/ enforce: 'pre' exclude: // use: loader: 'webpack-strip-block' options: blocks: blocks start: '/*' end: '*/' test: /\.html$/ enforce: 'pre' use: loader: 'webpack-strip-block' options: blocks: blocks start: '<!--' end: '-->' ;