babel7

使用babel7 进行转码

需要提前安装的东西:

  1. npx 方便执行命令
{
  "name": "TestBabel7",
  "version": "1.0.0",
  "dependencies": {
    "@babel/polyfill": "^7.6.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.6.4",
    "@babel/core": "^7.6.4"
  }
}

babel.config.js 配置

const presets = [
    [
        "@babel/env",
    ],
];

const plugins = [
    ["@babel/plugin-proposal-decorators", { "legacy": true }], // 装饰器
];

module.exports = { presets,plugins};

转换的命令

如: 将 js 目录下的文件 转换后 存放到 src目录下

npx babel js -d src

更多内容查看babel官网

猜你喜欢

转载自www.cnblogs.com/daihanlong/p/11693707.html