Skip to content

Instantly share code, notes, and snippets.

@akirattii
Last active November 22, 2016 11:59
Show Gist options
  • Save akirattii/540e7d59530c205528550b006e41be91 to your computer and use it in GitHub Desktop.
Save akirattii/540e7d59530c205528550b006e41be91 to your computer and use it in GitHub Desktop.
How to browserify & uglify ES2015 code
## Install browserify:
$ npm install -g browserify
# Install uglify-js:
### First remove already installed one:
$ npm remove uglify-js -g
### Install the ES2015 compatible version from 'harmony' branch:
$ npm install -g https://github.com/mishoo/UglifyJS2.git#harmony
# Try uglify of ES2015 code:
### 'input.js' is written in ES2015
$ uglifyjs --compress --mangle -- input.js
# browserify collaborate with uglifyjs:
$ browserify ./public/javascripts/app.js | uglifyjs > ./public/javascripts/bundle.min.js
# example output:
# bundle.js 2.4M (non-uglified)
# bundle.min.js 748K (uglified) <- Awesome!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment