File Watcher to minify SampleFile-dbg.js to SampleFile.js

Hi there,

I have a file called SampleFile-dbg.js, so this is the full source debug file.

I need to have a File Watcher to minify this file (using Google Closure Compiler, or any other minify tool). However, the destination file needs to be SampleFile.js.

How can this be done?

Examples:
SampleFile-dbg.js --> SampleFile.js
SampleClass-dbg.js --> SampleClass.js
AnotherLongNameClassFileName-dbg.js --> AnotherLongNameClassFileName.js

Are there any ideas?
I'm using WebStorm 7 on Windows 7.

Regards
Tobias

7 comments
Comment actions Permalink

Hi there,

I do not think that such macro is available.

You can try and write your own batch (or whatever) script that does such renaming (and calls actual file minification) and use it as actual program in file watcher settings.

Instead I would recommend naming the actual files differently (more standard approach these days):

  • SomeFile.js -- normal (developer/debug) version
  • SomeFile.min.js -- final (production) version


With this in mind it's easy to make SomeFile.js --> SomeFile.min.js

0
Comment actions Permalink

Hi Andriy

Thanks for your feedback. However, this development paradigm is defined by a JavaScript framework from SAP (SAPUI5, or the open source OpenUI5).

All the debug files are named FileName-dbg.js, and all minified productive usage files are just FileName.js. So I try to find a solution for this by using a File Watcher.

Minifying from SomeFile.js to SomeFile.min.js is easy, that's true. :)

Regards
Tobias

0
Comment actions Permalink

I have another question.

Is it possible to make the File Watcher process *-dbg.js files only?

Regards
Tobias

0
Comment actions Permalink

Sure.

Just create custom scope (Settings | Scopes) that would include desired files only (e.g. ALL *-dbg.js files in whole project.. or only in certain folder(s)).

Then use that scope in File Watcher settings.

0
Comment actions Permalink

I personally see only one way -- creating some script (e.g. batch .cmd .. or nodejs one etc) and pass file name to it. Such script would then build correct names and will actually execute minification process (call proper program with correct parameters).

Another option is pretty stupid/lame and may work for limited set of files only. The idea is to create separate File Watcher entry for each of such files (custom scope + hardcoded file names). Yes, this is stupid idea .. but it works.


P.S.
It's all because IDE does not have any special macros for such string manipulations. You can file new Feature Request ticket directly to the Issue Tracker -- if you provide good enough arguments with enough details I personally do not see why it cannot be implemented in upcoming v8.

0
Comment actions Permalink

Sure:) Settings/Scopes, add a new scope, set the following pattern for it: file:*-dbg.js
In file watcher settings, select the scope above as a watcher scope

0
Comment actions Permalink

Thanks a lot for all your feedback.

I will do a batch file. It will minify the SampleFile-dbg.js to SampleFile-dbg.js.min.js (stupid file name) and rename this to SampleFile.js.

And thanks for the hint about custom scopes. Haven't thought about this.

Regards
Tobias

0

Please sign in to leave a comment.