Problem with YUI Compressor

I setup a file watcher for yuicompressor - 2.4.8 and it crashes while trying to minify a css file.

Exception in thread "main" java.lang.reflect.InvocationTargetException
...
Caused by: java.lang.StackOverflowError

Now I did find a stackoverflow question on this at http://stackoverflow.com/questions/8831462/yuicompressor-crashes-stackoverflow-error
it seems that setting -Xss would fix the problem, but how do I set phpstorm to run the filewatcher with the -Xss setting, if I add it to the filewatcher arguments, it just triggers the "Usage: java -jar yuicompressor-2.4.8.jar [options] [input file]" error.

So the question is: How can I set -Xss with a filewatcher in phpstorm?

2 comments
Comment actions Permalink

To increase the stack size, you need passing -Xss option to java. Default is 512k, try increasing it, for example to -Xss2048k.

To do this, you either need to modify node_modules\yuicompressor\nodejs\cli.js accordingly, by adding args.unshift('-Xss2048k');:

var spawn = require('child_process').spawn,
    fs = require('fs'),
    compressor = require('./index'),
    args = process.argv.slice(2);

args.unshift(compressor.jar);
args.unshift('-jar');
args.unshift('-Xss2048k');
...


and then specify a path to yuicompressor binary in a Program field of your file watcher (like C:\Users\My.Name\AppData\Roaming\npm\yuicompressor.cmd).

Or, set up your file watcher in a different way, using java as a Program:

Program: C:\Program Files (x86)\JetBrains\PhpStorm 9.0.2\jre\jre\bin\java.exe
Arguments: -Xss2048k -jar "C:\Users\My.Name\AppData\Roaming\npm\node_modules\yuicompressor\build\yuicompressor-2.4.8.jar " $FileName$ -o $FileNameWithoutExtension$.min.css

1
Comment actions Permalink

Awesome thanks! I used the second way you suggested of setting the filewatcher to run java directly.

0

Please sign in to leave a comment.