package.json:
"devDependencies": {
? ? "@babel/cli": "^7.1.2",
? ? "@babel/core": "^7.1.2",
????"babel-loader":"^8.0.0",
????"@babel/polyfill":"^7.0.0",
? ? "@babel/preset-env": "^7.1.0",
? ? "@babel/plugin-transform-runtime": "^7.1.0",
? ? "@babel/runtime-corejs2": "^7.1.2",
? ? "@babel/plugin-transform-object-assign": "^7.0.0"
? }
.babelrc:
{
? ? "presets": [
????????[
????????????"@babel/preset-env", {
? ? ? ? ? ????? //是否將ES6的模塊化語法轉譯成其他類型
? ? ? ? ? ? ???? //參數(shù):"amd" | "umd" | "systemjs" | "commonjs" | false杠输,默認為'commonjs'
? ? ? ? ? ????? "modules": false,
? ? ? ? ????}
????????]
????],
? ? "plugins": [
? ? ? ? ["@babel/plugin-transform-runtime",{"corejs": 2}],
? ? ? ? "@babel/plugin-transform-object-assign",
? ? ]
? }
webpack.dev.config.js:
entry:['@babel/polyfill','./src/script/app.js'],
module:{ rules: [ { test:/\.js$/, exclude:/node_modules/, use: { loader:'babel-loader'} } ] },
main.js:
import '@babel/polyfill'