How to make File Watcher to save files in a different directory Follow
Hey there,
I am using File Watcher with UglifyJS to minify my javascripts.
However as I am also using require it would like to make myself a bit more easy and save the minified files somewhere else.
At this point this idea of saving it in anther directory made my life not a bit more easy but a bit more difficult.
First I found out that FileWatcher will also minify third party already minified files (it would come in handy not to miny files with the section .min.js in the name)
I can tackle that issue by just using development versions of every third party script.
But worst of all it seems I cannot change the directory of the minfied file... well I can but then it specifically for this project.
Let me explain what I would like to do:
I have this directory structure:
- /ProjectDir/FrontendDir/js/src/app/views/script.js
And saving the minified version I would like to have this:
-/ProjecDir/FrontendDir/js/min/app/views/script.min.js
Is there a way to do this nicely with the macro's?
Please sign in to leave a comment.
well,.min.js files are still JavaScript files, and watcher listens to all them by default.
I can suggest excluding minified files from watchers processing - create a new scope (Settings | Appearance&Behavior | Scopes) with minified files excluded (like file:.js&&!file:*.min.js), and choose this scope as your file watcher scope
Sure. Please try the following:
Arguments: $FileName$ -o $ProjectFileDir$/min/$FileDirPathFromParent(src)$$FileNameWithoutExtension$.min.js
Output paths to refresh: $ProjectFileDir$/min/$FileDirPathFromParent(src)$$FileNameWithoutExtension$.min.js
But note that UglifyJS doesn't create directories when generating files, so you have to create a directory structure yourself to avoid errors like 'ENOENT, no such file or directory'