3
votes

I have a shell script that collects all the .js files on a page and concats them to be compiled using the closure compiler. However, I don't want a specific js file to optimized any via the compiler. For example, I have the command to compile fileA.js, fileB.js, and fileC.js. How do I notate to skip fileB.js but still place it in the output file scripts.min.js in the correct order? So, fileA.js and fileC.js would be optimized using SIMPLE_OPTIMIZATION and fileB.js wouldn't be touched. Is there a keyword I can place in the comments of the file itself that says, skip this file?

java -jar compiler.jar --js=fileA.js --js=fileB.js --js=fileC.js --js_output_file=scripts.min.js
2
You shouldn't do this. Closure advises against mixing compiled and uncompiled code. What exactly are you trying to achieve that prevents you compiling all 3 files together?EMMERICH
Do A or C depend on B, or B on A or C? If not nullptr's suggestion is the answer, although you might still at least minify whitespace in fileB.Chris Moschini

2 Answers

2
votes

If I understand your intent here, you may consider processing each file that you want to minify separately, then performing the concatenation as a separate step. In pseudo-code:

minify fileA.js
minify fileC.js
cat fileA.js fileB.js fileC.js >scripts.min.js
1
votes

There is no keyword that you can place in any scope to say "ignore me". nullptr has the right suggestion. In our project we have created some simple preprocessing comments and use them to control the flow. However, you can only ignore and include a file before the minified code or after the minified code if you want to do it in one pass. So, nullptr's solution is the only one. Remember to use extern files so variable renaming (and not renaming) works properly.