Doing so means babel is run once for every input file, including anything imported from
node_modules. And as loaders switch over to returning ES2015 modules, we’d need to start running
Instead it’s preferable to pass webpack ES2015 code (which enables the new tree shaking feature) and then transform the entire bundle into ES5 in one operation. That’s the purpose of babel-webpack-plugin.
It works in almost exactly the same way as UglifyJsPlugin. Just add to the plugins list (before UglifyJs if you’re using it) and the code will be transformed from ES2015 to ES5 all in one go.
Add BabelPlugin to the list of plugins:
The options above are the default. For all available options, see
babel documentation here:babel-docs.