1.打包时出错且不压缩代码是因为没有正确的转换语法
npm install babel-core babel-preset-env babel-loader --save-dev
2.如果使用了async await等es7新语法还要安装
npm install babel-plugin-transform-runtime --save-dev
3.webpack.config.js中配置
module:{ rules:[ { test:/(\.jsx|.js)$/, use:{ loader:"babel-loader", options:{ presets:["env"] } }, exclude:/node_modules/ } ] }
4. .babelrc文件中配置
"plugins":[ [ "transform-runtime", { "helpers": false, "polyfill": false, "regenerator": true, "moduleName": "babel-runtime" } ] ]
原文地址:https://www.cnblogs.com/lvshoutao/p/11416630.html
时间: 2024-11-07 15:32:56