2

How can I improve the File Watcher to compile a SCSS to CSS after I press Cmd + S (for save)?

The problem is that the File Watcher compiled the files too quick so sometimes results in an error, because I'm still writing the function or CSS tags. That causes a lots of trouble and takes so much time and to be honest, disturbs the workflow.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • Show your File Watcher settings (expand all areas). There will be an option that will prevent auto-executing unless saved. – LazyOne May 10 '18 at 14:11
  • @LazyOne Thank you, that worked. But now sometimes an error occurs https://www.dropbox.com/s/o8av40rx2txn5qe/Screenshot%202018-05-11%2009.16.34.png?dl=0 . do you know why or what this is? – Sascha Rudolph May 11 '18 at 07:17
  • 1
    How long it takes to compile it? I see you are most likely using Ruby-powered compiler. Do you want to try [node-sass](https://github.com/sass/node-sass#command-line-interface) (`npm install node-sass -g`).. or [Dart powered one](http://sass-lang.com/dart-sass)? They are noticeable faster. Arguments are a bit different though .. but that just a matter of checking the right one with `--help` parameter, right? – LazyOne May 11 '18 at 08:02
  • No I've never tried, I thought there would be simply a method to make the time out longer so we can change it to 2 seconds or something similar. Currently the compiler takes 1 to 2 seconds to compile, depends on how large the file is. – Sascha Rudolph May 11 '18 at 08:50
  • 1
    1-2 seconds should not be a problem at all ... Maybe lena can give you better suggestion/answer -- she is from WebStorm team. – LazyOne May 11 '18 at 08:52
  • Thank you, really appreciate your help! – Sascha Rudolph May 11 '18 at 11:17

1 Answers1

7

In file watcher settings, Advanced options, try clearing Auto-save edited files to trigger the watcher checkbox:

enter image description here

the watcher will be triggered on explicit CMD + S/moving focus from the IDE only

lena
  • 90,154
  • 11
  • 145
  • 150
  • That helped, thank you! But do you get sometimes an error (yellow) below the code editor that says "File Watcher took too long and was canceld because of a timeout" (similiar like that, I dont know the exact error phrase)? – Sascha Rudolph May 10 '18 at 22:09
  • Currently autoupload works this way: after explicit save action IDE tries to wait till file watcher's tasks finish. It's done to upload transpiled files together with changed (see https://youtrack.jetbrains.com/issue/WI-16410). If it takes more than time limit (5 seconds), IDE stops waiting and just uploads all changed files, printing that 'Automatic upload: check for related changes from File Watchers took too much time and was cancelled.' message. – lena May 11 '18 at 09:25
  • And there is no way to rise the limit to about 6 or 8 seconds? I guess the compiler is done with his task because after the upload (shortly after the message pops in) the changed content is visible online. – Sascha Rudolph May 11 '18 at 13:58
  • 1
    this limit is not configurable afaik:( You can file a feature request to [youtrack](https://youtrack.jetbrains.com/issues/WI) on this – lena May 11 '18 at 14:49