0

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.

Mostafa
  • 119
  • 1
  • 13

3 Answers3

1

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

Ghazaleh Javaheri
  • 1,829
  • 19
  • 25
0

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

Oksana
  • 662
  • 3
  • 2
  • no, it won't preserve the structure inside the target dir;`-o $ProjectFileDir$/webapp/resources/js-min/$FileDirPathFromParent(js)$$FileNameWithoutExtension$.min.js` is better, but won't work on Windows anyway – lena Oct 04 '17 at 14:23
  • @Oksana I've tried a bunch of path patterns with macros like this and others, but unfortunately non of them worked. As I said in the comment section in lena's answer above, the problem arises when you have a path that has a ":" in it. Only relative paths would work. – Mostafa Oct 09 '17 at 09:22
0

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

lena
  • 90,154
  • 11
  • 145
  • 150
  • Yes, I'm on Windows. I guess you're right, whatever path I try with macros, has a problem, and that's because of inherent **YUI Compressor**'s problem with paths that have ":" in them. Surprisingly, there has been also a commit on the project code base in github for this issue, but it seems that it's not bundled in any version. [link](https://github.com/yui/yuicompressor/commit/350933e2ef1651b3631ea4b1898b8e40f9f18aaf) – Mostafa Oct 09 '17 at 08:21
  • What other JS minifier you would suggest? – Mostafa Oct 09 '17 at 09:19
  • I'd suggest [UglifyJS](https://www.npmjs.com/package/uglify-js); [Closure](https://www.npmjs.com/package/closure) can also be considered – lena Oct 09 '17 at 15:07