babel7

Use babel7 transcoding

Need to install something in advance:

  1. npx easy to execute commands
{
  "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 Configuration

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

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

module.exports = { presets,plugins};

Conversion of command

Such as: js directory under the file conversion is stored to the src directory

npx babel js -d src

View more content babel official website

Guess you like

Origin www.cnblogs.com/daihanlong/p/11693707.html