4

Possible Duplicate:
How can I combine and compress multiple script and css files for production use?

I would like to compress multiple javascript files into one minified file. I'm using YUI Compressor. On their page it says that it can do it like so (their example uses css files but I replaced it with js):

java -jar yuicompressor.jar -o '.js$:-min.js' *.js 

When I try to execute this I get an empty file named .js$

What am I missing?

Community
  • 1
  • 1
dev.e.loper
  • 35,446
  • 76
  • 161
  • 247
  • Do you have any js files in the directory? I tried the same on my local and it works perfectly fine. What is the Operating System that you are using? Perhaps, if you are using Windows, try the Windows port of `yuicompressor`. – Srinivas Dec 19 '12 at 17:29
  • 1
    Maybe something useful here http://stackoverflow.com/questions/632725/how-can-i-combine-and-compress-multiple-script-and-css-files-for-production-use – mkey Dec 19 '12 at 17:30
  • @Srinivas yup I have js files in that same directory as the yuicompresssor file – dev.e.loper Dec 19 '12 at 17:32
  • Maybe something like this `java -jar yuicompressor.jar --type js --nomunge -o '.js$:min.js' '*.js'` – mkey Dec 19 '12 at 17:35
  • @mke that still gives me an empty .js$ – dev.e.loper Dec 19 '12 at 17:37
  • I think you should count your losses here and either try the .net version of yui or use a command line shell script to do things the "crude" way. Maybe there's a problem with JS files, have you tried doing the same on CSS files? – mkey Dec 19 '12 at 17:42
  • I second the .net version of YUI, which incidentally *only* supports creating a single output file at once heh. I wrote a [blog post](http://blog.kitchenpc.com/2012/11/14/a-better-way-to-deploy-technical-debt-part-53/) about integrating it into MSBuild as well. – Mike Christensen Dec 19 '12 at 17:50

1 Answers1

3

The following works for me: java -jar yuicompressor.jar *.js > combined.js

potato
  • 471
  • 2
  • 13
  • That works. For some reason though, the file produced by this is larger than the file I'm generating by looping through files, calling yuicompressor for each one and appending to resulting file. Weird but thanks. – dev.e.loper Dec 19 '12 at 18:38
  • 14
    I don't advise using `*.js` as js is order dependent. It'll be just by pure luck if `combined.js` included files in the right order. – Reactgular Mar 02 '14 at 22:56