UglifyJS file watcher in IDEA minifies already minified files during Ant build

(This is a near-clone of a StackOverflow question I asked, please feel free to respond there or here.)


I have an UglifyJS file watcher set up in IDEA, and it works great while I'm editing -- I modify the source js, the minified version gets created next to it automatically.

However, when I run an Ant build, and it copies the minified versions into the build working dir, the watcher "helpfully" creates doubly minified versions of them (*.min.min.js) in the build working dir, not ok.

I've set the Scope of the watcher to the 'src' module, but apparently that doesn't do what you'd think it would, because the doubles get created when Ant copies files into the 'build' module. Happens when I use IDEA to manually copy a single file from src to build too.

I don't see how to set this up to include *.js but exclude *.min.js, which is really the right thing. (Seems so sensible that Uglify should have it built in, but far as I can see it doesn't.)

Other than getting rid of the watcher and scripting the build do the minification, or copying only the original js versions and letting the watcher (re)create the minified ones, what's the best way to go here?

3 comments
Comment actions Permalink

.min.js files are still JavaScript files, and watcher listens to all them by default.
As a workaround 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

0
Comment actions Permalink

Thanks Elena, I''ll look into that when I have a chance.

Two questions:

  • Is it possible to configure Uglify itself to ignore minified files? It seems really necessary, so I'd be surprised if that wasn't already handled, but I didn't see a way to do that.
  • Why doesn't scoping the watcher to my 'src' module work? Is that a bug, or do I misunderstand what that's supposed to do?


Thanks again.

Dave

0
Comment actions Permalink

Got this working, thank you. Pattern I ended up with was this, for anyone with similar needs:

file[src]:*.js&&!file:*min.js*

Making the 'src' module current then opening the dlg and selecting it from the dropdown in the main watcher config window apparently doesn't actually filter by that module. Clicking the ... btn, then choosing it from the dlg that opens does, plus I added the already minified exclusion too.

Works great now, far as I've tested (both a minimal Ant test and manually copying a file to 'build' in IDEA).

Thanks again.

0

Please sign in to leave a comment.