compress all js in a folder to new folder useing google closure compiler?

余生长醉 提交于 2019-12-06 11:52:24

问题


how can i compress all my js in a folder to a new folder ?

i have search around google and stackoverflow, what i found is just Compress all file .js with Google Closure Compiler Application in one File that puting it all to one.. + can we put a wildcard or something?

so i can do something like

java -jar bin/compiler.jar ../../path/my/*.js --js_output_file ../../path/new/*.js

thanks for looking in

Adam Ramadhan


回答1:


Bash scripting to the rescue. Something like

files=`find ../../path/my -name "*.js"`
for i in $files;
do
    java -jar bin/compiler.jar $i --js_output_file `dirname $i`../new/$i.js
done

(not tested)




回答2:


I've got a bash script on gitub for this, https://github.com/fatlinesofcode/compile-js

works like this

compile-js build ../../path/new/output.min.js ../../path/my/*



来源:https://stackoverflow.com/questions/6871908/compress-all-js-in-a-folder-to-new-folder-useing-google-closure-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!