Babel is a compiler for writing next generation JavaScript.
A babel plugin (not a loader) for webpack.
Webpack 2 can handle native ES2015 modules, so there's no need to run babel's es2015
preset on every module before passing it to webpack. Doing so just adds to compile time. In addition, as loaders are updated to return ES2015, you would need to add a babel-loader to the top of the chain for every single filetype.
This plugin runs babel only once per asset, at the end of the compilation process.
npm install babel-webpack-plugin
Add BabelPlugin to the list of plugins.
var BabelPlugin = require("babel-webpack-plugin");
plugins: [
new BabelPlugin({
test: /\.js$/,
presets: ['es2015'],
sourceMaps: false,
compact: false
})
]
The options above are the default, see all options for babel
here.