babel

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的模块化语法转译成其他类型

                 //参数:"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'

你可能感兴趣的:(babel)