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" } ] ]