Use Closure Compiler Command Line Minify and Repla

2019-01-28 17:52发布

问题:

I tried

java -jar compiler.jar --js jj.js --js_output_file jj.js

The output file size is 0.

If I do not want to do a renaming from .min.js to .js, what should I do?

回答1:

The compiler doesn't not support this. I believe the next release will actually fail before overwriting the file.



回答2:

It isn't possible - for safety's sake although the following bash script achieves what you want to:

#!/bin/sh
for js in $(find ./public_html -name *.js)
do
        java -jar compiler.jar --js $js --js_output_file $js.min
        mv $js.min $js
done