Ad

PHPStorm Change In Minified JS Code On Closure Compiler

using Closure Compiler, I'ld like to change a value in the JS minified file.

Per example, code in unminified:

var color = 'blue';

And in minified:

var color = 'red';

Or, if it's easiest:

var color = '$COLOR';

And then, on closure, the variable $COLOR is replaced by red. Any idea how to do that in last PHPStorm version? My file watcher use NodeJS.

Thank you.

Ad

Answer

well, you can't expect any magic from a file watcher - the latter is just a way to assign an external tool that has a CLI as a watcher to certain files, so that this tool is triggered each time these files change. If the tool itself is not able to perform certain things, there is no way to set up a watcher to do these things for you. In particular, Closure Compiler doesn't have any options allowing to replace variable values while minifying files. You can use Grunt here, for example - grunt-replace allows replacing files contents based on patterns, and combine it with grunt-closure-compiler

Ad
source: stackoverflow.com
Ad