Webpack es2015 wood shake with reaction

I would like to use the tree shake function, so we do not need to install babel-preset-es2015-webpack. We can still use babel-preset-es2015 and set the module flag to false to pre-configure es2015. I changed the configuration of my web package as shown below, as a result of which an unexpected token import error occurred in my react components in the import line.

module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'babel', query: { presets: [['es2015', {modules: false}], 'react'] } }, { test: /\.scss$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader!sass-loader") } ] } 

I also tried setting the presets as ['es2015', 'react', {modules: false}] Then I got another error on the console
Module build error: ReferenceError: [BABEL] C: \ FE-Proj-Templates \ webpack \ main.js: using remote version of Babel 5: foreign.modules - use the appropriate module to convert the module to plugins option. Check out http://babeljs.io/docs/plugins/#modules

How to set the es2015 preset with the false flag of modules, and also use the React preset?

+5
source share
1 answer

It updates and works.

 presets: [['es2015', {modules: false}], 'react'] 
+12
source

All Articles