21

I've installed the nodejs plugin in PHPStorm and setup the yuicompressor npm for minifying css/js.

I got the file watcher working so that .min.css files are produced automatically whenever i make changes to .css/.js files in the project, but notice the file watcher only kicks in on existing files if I make a change to the file.

So, if .css/.js files already exist in a project which do not require any changes, the newly defined file watcher doesn't run on them unless you go in and make a change on each file you want minified (or touched some other external way).

Assuming you have an existing project with existing .css/.js files which don't require changes, is there an easy way to run PHPStorm File Watchers without having to change the files first?

1 Answer 1

43
  1. Select such file(s)/folder(s) in Project View panel
  2. "Help | Find Action" (Ctrl + Shift + A), activate check box for better results
  3. Search for "run file w" (without quotes, obviously) and choose Run File Watchers entry

Alternatively:

  1. "Settings | Keymap"
  2. Find that Run File Watchers action (under "Plugins | File Watchers" branch)
  3. Assign some custom shortcut
  4. Select desired file(s)/folder(s) in Project View panel
  5. Use that shortcut from step 3

Alternatively:

  1. "Settings | Menus and Toolbars"
  2. "Project View Popup Menu" branch
  3. Find desired location and click on "Add After..." button
  4. Locate Run File Watchers action (it's under "Plugins | File Watcher" branch) and click on "OK" button
  5. The action is now accessible via content menu in Project View panel and can be used on desired files and folders.
6
  • 3
    Excellent! One would think this SHOULD be available on a context menu, i.e., when selecting files in a project, the right-click context menu should have an entry for Run File Watchers. It shouldn't be buried in non-menu item commands.
    – lvpro
    Nov 16, 2013 at 0:15
  • 1
    YES -- every single action into context menu.. so you have to scroll 2 or more screens to reach the command located at the bottom... NO thank you. But I agree - this functionality is not easily discoverable .. but placing every option into context menu is definitely wrong way to go: 1) you can place it there yourself at any time (it is customisable); 2) the main idea of File Watcher is to execute something on save while the above functionality is just a nice specific bonus; 3) Check available actions at Settings | Keymap -- you will find quite a lot of not-widely-advertised functionality
    – LazyOne
    Nov 16, 2013 at 0:43
  • 1
    You have to abstract from/understand one thing: not every person needs this action, especially if it is not the main one. For you this one is important -- for other 10 users 10 other different actions are much more important than this (simply because they do not use File Watchers plugin at all). You cannot satisfy everyone with default settings. That's why IDE comes with most commonly used actions only .. while providing you the way to customize it to your specific needs.
    – LazyOne
    Nov 16, 2013 at 0:51
  • 2
    Today you have learned (or possibly reminded) the power of Ctrl+Shift+A -- now you know what you have to use first next time you will be in similar situation. Same goes for search in Settings screen -- top left corner -- it does magic if you are new to the IDE or simply do not remember where specific option is located (or just feel lazy to manually navigating there trough all those options). If nothing found -- try synonym/sumilar keyword (e.g. cursor vs caret etc). New day -- new knowledge :)
    – LazyOne
    Nov 16, 2013 at 0:56
  • 2
    LazyOne, I respectfully disagree with your sarcasm. If one enables file watchers in the IDE, he/she has implied his intent to the system that he is using this feature, therefore, it would make sense to then enable this option on a context menu automatically. However, I do agree if one has not configured any file watchers, it would be non sensical to have it as context menu option. We can agree to disagree. I do sincerely appreciate your help today.
    – lvpro
    Nov 16, 2013 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.