1: initializes package.json

npm init
Copy the code

2: Install babel-PRESET – ES2015 (in production)

npm install babel-preset-es2015 --save-dev
Copy the code

3: Add the. Babelrc file to the package.json sibling directory

  • And add the following
{
    "presets": ["es2015"]}Copy the code

If global Babel installation is required: NPM install –global Babel -cli

4: Convert ES6 to ES5

babel js/src -d js/build
Copy the code

5: Use Browserify for packaging

  • Note: ES5 files are packaged
browserify js/build/main.js -o js/dist/bundle.js
Copy the code

6: Import bundle.js files

This article is a supplement to this article:

Es6-49: Modular