JS Minify Windows 运行 Uglifyjs - 2877206/docs GitHub Wiki

https://www.npmjs.com/package/uglify-js

Install First make sure you have installed the latest version of node.js (You may need to restart your computer after this step).

From NPM for use as a command line app:

npm install uglify-js -g From NPM for programmatic use:

npm install uglify-js From Git:

git clone git://github.com/mishoo/UglifyJS2.git cd UglifyJS2 npm link . Usage uglifyjs [input files] [options] UglifyJS2 can take multiple input files. It's recommended that you pass the input files first, then pass the options. UglifyJS will parse input files in sequence and apply any compression options. The files are parsed in the same global scope, that is, a reference from a file to some variable/function declared in another file will be matched properly.

If you want to read from STDIN instead, pass a single dash instead of input files.

If you wish to pass your options before the input files, separate the two with a double dash to prevent input files being used as option arguments:

uglifyjs --compress --mangle -- input.js

uglifyjs -c -m JS/.js JSM/.min.js

You can use this configuration in gruntfile.js:

uglify: { all: { files: [{ expand: true, cwd: '', src: ['**/.js', '!.min.js'], dest: '', ext: '.js' }] } }

make a bat file with start at each row beginning

start uglifyjs app\main.js -mt sort -c -e -o app\main.ug.js start uglifyjs app\lib.js -mt sort -c -e -r myfunctionname -o app\lib.ug.js start uglifyjs app\controllers\bbbCtrl.js -mt sort -c -o app\controllers\bbbCtrl.ug.js start uglifyjs app\controllers\aaaCtrl.js -mt sort -c -e -o app\controllers\aaaCtrl.ug.js

Windows通过Node.js 运行uglifyjs

http://www.cnblogs.com/sorex/archive/2011/12/14/2287635.html

修改配置

上述安装后自动生成的配置文件是不可直接使用的,我们需要手工去修改。

打开C:\Users\Administrator\AppData\Roaming\npm\uglifyjs.cmd

内容为:

:: Created by npm, please don't edit manually. "%~dp0.\node_modules\uglify-js\bin\uglifyjs" %* 修改为:

:: Created by npm, please don't edit manually. @IF EXIST "%~dp0""node.exe" ( "%~dp0""node.exe" "%~dp0.\node_modules\uglify-js\bin\uglifyjs" %* ) ELSE ( node "%~dp0.\node_modules\uglify-js\bin\uglifyjs" %* ) 五、使用uglifyjs对javascript进行压缩美化

压缩:

uglifyjs f.js > f.min.js 美化:

uglifyjs -b f.min.js > f.b.js

安装、压缩

http://www.zhangxinxu.com/wordpress/2013/01/uglifyjs-compress-js/