简体   繁体   中英

combining multiple .js files into one in a build process

Any tips on combining multiple .js files into 1 (for a build process).

Will yuicompressor do this?

YUI Compressor can do this very easily, just send in the file names into YUI as arguments and it will output them as one file.

For example

> yuicompressor-2.4.2 file1.js file2.js file3.js -o combined.min.js

总是旧的备用(没有压缩像YUI压缩器) cat file1.js file2.js > newfile.js

This worked for me

cat file1.js file2.js file3.js | yuicompressor-2.4.2 --type js -o combined.min.js

And if order is not important

cat *.js | yuicompressor-2.4.2 --type js -o combined.min.js

If doesn't work

yui-compressor file1.js file2.js file3.js -o combined.min.js

try this:

for file in file1.js file2.js file3.js
do
  yui-compressor $file >> combined.min.js
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM