Output minified javascript file to a different directory with YUI Compressor File Watcher in IntelliJ

869 views Asked by At

I'm using YUI Compressor JS as my file watcher in intellij to minify my javascript files. The compressor works fine when i set 'Arguments' and 'Output path to refresh' parameters like below:

Arguments = $FileName$ -o $FileNameWithoutExtension$.min.js   
Output path to refresh = $FileNameWithoutExtension$.min.js 

It then produces the minified file in the original file's folder. What I can not achieve here is that I want minified files to be placed in some other directory.
So far I tried to set the two aforementioned parameters with values below:

Arguments= $FileName$ -o $FileParentDir$-min\$FileDirName$\$FileNameWithoutExtension$.min.js   
Output paths to refresh = $FileNameWithoutExtension$.min.js

But it then generates the minified version of the javascript file and overwrites it to the original file; prompting me with 'File Cache Conflict' dialoge like below.
File Cache Conflict Dialoge Image
My original javascript files reside in 'webapp/resources/js' folder, but I want minified files to be generated in 'webapp/resources/js-min' folder with the same structure as in 'webapp/resources/js' folder.

3

There are 3 answers

2
Oksana On

Have you tried $FileParentDir$/js-min/$FileNameWithoutExtension$.min.js?

3
lena On

Are you on Windows? YUI Compressor doesn't seem to accept Windows absolute path as a -o value... When I run java -jar yuicompressor-2.4.8.jar -v -o C:\WebstormProjects\untitled3\webapp\resources\js-min\sub\subsub\f3.min.js f3.js, no f3.min.js is produced, the original file is modified instead:( As far as I can see from the last comment in https://github.com/yui/yuicompressor/issues/78 thread, the bug should be fixed in yuicompressor-2.4.9. But this version is not available at https://github.com/yui/yuicompressor/releases, and the link to jar provided in comment seems to be outdated... In general, I'd strongly recommend using a different JS minifier, as YUI Compressor looks dead - no updates since 2013

0
Ghazaleh Javaheri On

n the Arguments text box, type: $FileName -o /your_custom_directory/ the Arguments pass to compresssor and it put your out put file in your_custom_directory then in "out put path to refresh" insert your_custom_directory too,this pass to phpstorm for indexing file

for me its like this

js>my_js_file js>min>result

Arguments: $FileName$ -o $FileDir$/min/$FileNameWithoutExtension$.min.js output paths to refresh:/min