使用Babel编译

安装babel包babel-core``babel-loader``babel-plugin-transform-runtime``babel-polyfill``babel-preset-es2015

webpack.config.js 配置文件

modules.exports = {
    ...
    entry: { name: ['babel-polyfill'], 'path/to/file.js' },  // 在入口文件添加babel-polyfill
    ....
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader'
            }  // 添加loader
        ]
    }
}

.babelrc 配置文件

{ 
  "presets": [ 
    "es2015" 
  ],
  "plugins": [
    "transform-runtime"
  ] 
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2021-11-26
  • 2021-10-24
  • 2022-12-23
相关资源
相似解决方案