Is there any module in NodeJS to concatenate and minify JavaScript files?
If you already have uglify-js
, your code uses some of the latest ES6 features (ECMAScript 2015) and it just gave you back parse errors on the first run, then install uglify-es:
npm install uglify-es -g
Or:
npm install mishoo/UglifyJS2#harmony
The explanation is in uglify-js-es6 package:
This is a temporary package containing the latest release of the 'harmony' branch of uglifyjs (UglifyJS2).
You can still run it normally with the uglifyjs
command. A compress and mangle example:
uglifyjs -c -m -o js/es6stuff.js -- js/es6stuff/*.js
Which will produce a single file with all the JS files of a folder. The double dash (--
) just prevents input files being used as option arguments.