webpack4将ES6转化成ES5如何配置
emer 发布于 2021-3-3 16:07 1573 次阅读
1、安装如下模块(webpack 4.x | babel-loader 8.x | babel 7.x)
npm i -D babel-loader @babel/core @babel/preset-env
或者安装如下模块(webpack 4.x | babel-loader 8.x | babel 7.x)
npm i -D babel-loader@7 babel-core babel-preset-env
2、在webpack.config.js中写如下配置
rules: [
{ "test":/.m?js$/, use: {loader:"babel-loader", options:{presets:["@babel/preset-env"]}}, exclude:/node_modules|bower_components/}
]