Question: What module can strip debugs in webpack solutions?

Question

What module can strip debugs in webpack solutions?

Answers 2
Added at 2017-01-03 04:01
Tags
Question

I am running a reactjs app with gulp/webpack and tried this: https://github.com/yahoo/strip-loader. However it does not work( throws errors in my reactjs code). How to get it working or what is another solution?

EDIT I added this to the loaders section of the webpack.config:

new webpack.optimize.UglifyJsPlugin({
    drop_debug: true
})

I have installed the plugin with npm but it does not filter the debugger statements from my reactjs code?

Answers to

What module can strip debugs in webpack solutions?

nr: #1 dodano: 2017-01-03 06:01

You can use UglifyJsPlugin() and pass the drop_debugger: true property.

To utilize this property you need to pass it to the compress property inside of the options argument.

new webpack.optimize.UglifyJsPlugin(
  compressor: {
    drop_debugger: true
  }
);

This is an UglifyJS specific property and webpack can pass those directly through compress. Ironically looking at the source of the plugin it can also take the property compressor as an alt property.

nr: #2 dodano: 2017-01-03 07:01

you can use strip-loader plugin in webpack.

var WebpackStripLoader = require('strip-loader');
WebpackStripLoader.loader('console.log', 'console.error', 'debugger')
Source Show
◀ Wstecz