[JavaScript] 使用uglify-js压缩合并js文件

语法:uglifyjs [input files] [options]

例如:

node ../thirdpart/uglify-js/node_modules/uglify-js/bin/uglifyjs ^
../thirdpart/underscore/underscore-1.6.0.js ^
../thirdpart/jquery/jquery-1.11.1.js ^
../thirdpart/jqueryplugin/pluginmanager.js ^
../thirdpart/jqueryplugin/dbexecutor/dbexecutor.js ^
../thirdpart/jqueryplugin/recordlist/recordlist_init.js ^
../thirdpart/jqueryplugin/recordlist/recordlist_static_set.js ^
../thirdpart/jqueryplugin/recordlist/recordlist_static_page.js ^
../js/content/contentdboperation.js ^
../js/content/contentlist.js ^
-o ../js/content/contentlist.min.js ^
--source-map ../js/content/contentlist.min.js.map ^
--source-map-url contentlist.min.js.map ^
--source-map-root  ../ ^
-c

(1)其中行尾的^在cmd中表示换行
(2)uglifyjs是nodejs库,安装方法:npm install uglify-js
(3)-o, --output: Output file (default STDOUT).输出,到文件或标准输出流。
(4)--source-map:Specify an output file where to generate source map.min文件地址。
(5)--source-map-url:The path to the source map to be added in //# sourceMappingURL. Defaults to the value passed with --source-map.是map文件相对于min文件的地址。
(6)--source-map-root:The path to the original source to be included in the source map.源文件的根目录地址,用来在出错的时候下载源文件。
(7)-c, --compress:Enable compressor/pass compressor options. Pass options like -c hoist_vars=false,if_return=false. Use -c with no argument to use the default compression options.压缩。
(8)github地址:https://github.com/mishoo/UglifyJS2

你可能感兴趣的:([JavaScript] 使用uglify-js压缩合并js文件)