参照:https://www.npmjs.com/package/cordova-uglify
安装:npm install cordova-uglify
安装完成之后,打开:
hooks/uglify-config.json
{ "alwaysRun": true, "recursiveFolderSearch": true, "foldersToProcess": [ "js", "css", ], "uglifyJsOptions": { "compress": { "drop_console": true }, "fromString": true }, "cleanCssOptions": { "noAdvanced": true, "keepSpecialComments": 0 } }
修改:alwaysRun": true,
运行:cordova build android
解压apk可以看一下js与css文件已经被压缩处理了.