I'm totally new to all the node shenanigans and don't quite know the best solution for the issue I have, maybe someone can point me towards the best solution towards it.
I have a setup with the framework Buddy to compile coffeescript into JS, all runs smoothly. What I need now is some tool to merge and preferably uglify and mangle the scripts together into one script.
Buddy has a nice setup where it auto-compiles the scripts upon save, is there such a tool that also watches and does said operations after Buddy has done its thing?
There is a module for node js called uglify-js which handles minification
To install it run:
npm install -g uglifyjs
It will install a command line utility, which accepts files from standard input and outputs to standard output the minified result.
To concatenate you can simply use cat
command line utility.
You can concatenate all the CoffeeScript files before the minimization or after.
Both have tradeoffs.
By concatenating before, you will avoid dublication of some supporting code that coffeescript generates, but will loose the wrapping to (function(){ /* your generated code here*/ })()
that CoffeeScript generates to avoid poluting the global scope.
See brunch. It include builder, linter, concatenator, minifier, source watcher and another useful tools.