compress all js in a folder to new folder useing g

2019-04-13 07:46发布

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

2条回答
够拽才男人
2楼-- · 2019-04-13 08:19

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/*

查看更多
霸刀☆藐视天下
3楼-- · 2019-04-13 08:27

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)

查看更多
登录 后发表回答