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.
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
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM