简体   繁体   中英

How to make webpack compile in ES6?

I have Webpack 2.x. By default this compiles the code in ES5. How to change it?

By default, you are supposed to have a loader for your webpack compiled files. You can take a look at the babel-loader. Include it in your webpack config, and you should be able to configure it to transpile to ES6.

You can use babel preset env to target the browsers and not include IE in the list and probably the specific versions of browsers you are using. That should transpile only to latest versions. Otherwise you can specify specific presets that you want to transpile in the babelrc file to only transpile those.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM