I have an app in nodejs. In it, I define some global variables that are shared across multiple files. For example:
//common.jsasync = requires("async");isAuthenticated = function() { //... return false;};//run.jsrequire("common.js");async.series([function () { isAuthenicated();}], function () { console.log("done");});
I want the async
and isAuthenticated
variables to be minified, but minified to the same thing in all files. It would look like the following:
//common.min.jsa = requires("async");b = function() { //... return false;};//run.min.jsrequire("common.js");a.series([function () { b();}], function () { console.log("done");});
How to do it in uglifyjs?
I'm currently looping through the files and using the command uglifyjs $file -m "sort,toplevel" -c > $file.min
on each.