babel7

百般思念 提交于 2019-12-01 16:40:13

使用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官网

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!