[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).輸出,到文件或標(biāo)準(zhǔn)輸出流。
(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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容