webpack es6转换成es5

  • npm install -D babel-loader @babel/core @babel/preset-env

  • 配置webpa.config.js的模块

module: {
  rules: [
    {
      test: /\.js$/,
      exclude: /(node_modules|bower_components)/,
      use: {
        loader: 'babel-loader',//使用 babel-loader
        options: {
          presets: ['@babel/preset-env']//包含es6转成es5的模块
        }
      }
    }
  ]
}
  • npm run build

发布了21 篇原创文章 · 获赞 0 · 访问量 325

猜你喜欢

转载自blog.csdn.net/weixin_46337813/article/details/104621721