Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off babel minification in webpack?

Here is the webpack configuration I use to prepare for production script

  config.output.filename = '[hash].main.js';

  config.module.loaders.push({
    test: /\.js$/,
    loaders: ['babel'],
    exclude: /node_modules/,
    include: path.join(__dirname, 'app'),
  });

However for debug purpose I want to be able to generate the final output xxxx.main.js without any minification or optimisation.

How can I achieve that with the above configuration?

I am actually not very familiar with webpack/babel tooling so I actually not sure if it is babel or webpack which executed the minification

like image 829
Anthony Kong Avatar asked Apr 09 '17 09:04

Anthony Kong


1 Answers

It is almost certainly webpack which minifies your bundle, babel would only minify the sources passed through the loader, not the entire bundle.

There are two ways you could have enabled minification, adding the UglifyJsPlugin to your config or using the CLI flag --optimize-minimize or -p which enables production mode which automatically sets --optimize-minimize.

If you're using the plugin, you can remove it from plugins in your config (or set it conditionally for example with an environment variable), and if you're using one of the mentioned flags you can simply run webpack without them to get the non-minified bundle.

See also Building for Production.

like image 155
Michael Jungo Avatar answered Nov 11 '22 16:11

Michael Jungo