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
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?

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);


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

Comment actions Permalink

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


Please sign in to leave a comment.