Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
941 views
in Technique[技术] by (71.8m points)

powershell - How can I combine and compress multiple script and css files for production use?

I want to use YUI Compressor to combine and compress my css and js file sets when I compile my project. YUI Compressor only takes as input single files. I've tried using the following (Windows) commands to append to the output files, but strange characters appear in the output where appendage occurs. How can I use windows command line or powershell to achieve this?

java -jar yuicompressor-2.4.2.jar --charset utf-8 jquery-1.3.2.js > scripts-all.min.js
java -jar yuicompressor-2.4.2.jar --charset utf-8 jquery.superfish.js >> scripts-all.min.js
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

My simple solution (before knowing about the .NET port of YUI Compressor) was to:

copy /b jquery.js+jquery.superfish.js+jquery.qtip.js+NOTICE core.js
java -jar yuicompressor-2.4.2.jar --charset utf-8 -o core-min.js core.js

That has been working fine for me even though I can't quite understand why the /b (binary) flag was the trick that got rid of the strange characters. If anyone wants to enlighten me in a comment I'd appreciate it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...