1: Initialize package.json
npm init
2: Install babel-preset-es2015 (in a production environment)
npm install babel-preset-es2015 --save-dev
3: Add a .babelrc file in the same level directory of package.json
- And add the following content
{
"presets": ["es2015"]
}
If you need to install babel globally:
npm install --global babel-cli
4: Convert ES6 to ES5
babel js/src -d js/build
5: Use browserify to package
- Note: The packaged is ES5 file
browserify js/build/main.js -o js/dist/bundle.js