Vue .babelrc配置

在VUE开发过程中。需要使用babel来讲ES6及其以上的语法转化成可以被是识别的语法。因此需要使用:babel-loader.

babel-loader7.x 需要使用的插件 以及.babelrc 文件中的内容

npm i -D babel-core babel-loader babel-plugin-transform-runtime
npm i -D babel-preset-env babel-preset-stage-0
{
  "presets": ["env", "stage-0"],
  "plugins": [
    "transform-runtime"
  ]
}

babel-loader8.x 需要使用的插件。以及.bablerc文件中的内容

npm i @babel/core babel-loader @babel/plugin-transform-runtime @babel/plugin-proposal-object-rest-spread -D
npm i @babel/preset-react @babel/preset-env babel-preset-mobx -D
npm i @babel/runtime -S
{
  "presets": ["@babel/preset-react", "@babel/preset-env", "babel-preset-mobx"],
  "plugins": [
    "@babel/plugin-transform-runtime",
    "@babel/plugin-proposal-object-rest-spread",
    "transform-remove-strict-mode" // 去除严格约束时使用
  ]
}
// babelrc为json文件不可以有注

报错:

"use strict" 使用插件 babel-plugin-transform-remove-strict-mode  之后在.babelrc中加上

'@babel/core' 就是babel-loader和babel-core的版本不匹配。

posted @ 2019-11-08 11:25  jisa  阅读(6385)  评论(0编辑  收藏  举报