首页 > 其他分享 >vue webpack 配置babel es6转化转化es5

vue webpack 配置babel es6转化转化es5

时间:2023-12-07 11:57:17浏览次数:31  
标签:npm es6 es5 vue plugin babel 转化 preset runtime

1、安装相关依赖

npm i -D @babel/[email protected]
npm i -D @babel/[email protected]
npm i -D [email protected]


// 语法中有 async await 等
npm i -D @babel/[email protected]
npm i -D @babel/[email protected]

2、babel.config.js

module.exports = {
  presets: [
    // https://github.com/vuejs/vue-cli/tree/master/packages/@vue/babel-preset-app
    '@babel/preset-env', '@vue/cli-plugin-babel/preset'
  ],
  plugins: [
    '@babel/plugin-transform-runtime'
  ],
}

3、vue.config.js

module.exports = {
  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
            options: {
              presets: ['@babel/preset-env']
              // plugins: [
              //   ['@babel/plugin-transform-runtime']
              // ]
            }
          }
        }
      ]
    }
  }
}

标签:npm,es6,es5,vue,plugin,babel,转化,preset,runtime
From: https://www.cnblogs.com/rzl795/p/17881373.html

相关文章