Autoreload file system changes in phpstorm/webstorm/intellij - intellij-idea

Ahoi
I have an project with grunt, and whenever I save a file it runs the csscomb script in the grunt:watch task. My old "IDE" Sublime reloaded the changes automatically, phpStorm doesn't do that. I always have to manually synch the file.
The whole problem is that I write code, save in between and continue programming, and then the popup about the file system changes appears.
LG

Do you run grunt:watch outside of webStorm, or using Grunt console? In the latter case, the file system should be synchronized when task is completed. But if the task is run externally, outside of webstorm, you have to synchronize files manually

I know this is old stuff, but I had the same problem with WebStorm - i.e grunt running externally on a network server.
I just unchecked "use safe-write ..." in Settings > Appearance & Behaviour > System Settings and now my WS writes saves directly to the file triggering watch grunt tasks.

Try Preferences -> Appearance & Behavior -> System Settings -> Synchronize files on frame activation. PHPStorm will automatically reload file system changes once you switch to its window.

Related

WebStorm saves files on edit

My JetBrains WebStorm gone crazy and started to save files right after I type the character. Autosave settings are disabled (I like to save files manually). Any ideas why this could happen or how to fix it?
WebStorm doesn't normally auto-save files on each key pressing. If it only happens while debugging your app, check if Live Edit (that is active during debug session) is enabled in Preferences | Build, Execution, Deployment | Debugger | Live Edit - it auto-saves files to provide live reload. Some other plugins can also be responsible for auto-saving - for example, third-party SonarLint and ESLint plugins are known for causing such issues, as they save files to run analysis on the changes, Flow service, when enabled, flashes files to disk to submit up-to-date files to Flow type checker, etc.
I'd also suggest to check if you have any file watchers set up in Preferences | Tools | File Watchers - those watchers that have Auto-save edited files to trigger the watcher enabled can cause auto-saving of the files included in watcher scope

Use Intellij File Watcher only on Open File

I've been using the Intellij Golang plugin recently (it's great) but I've been running into an issue with the File Watchers I set up. My working directory is set to my $GOPATH directory and I would like to be able to run golint and goimports after I save a file I'm working on. The issue I have is if I use git to clone a repo the next time I open Intellij it runs both golint and goimports on all the newly imported files which can take a long time for large projects. Is there a way to set up File Watcher so it only watches a file that is currently open? I added a screenshot of my current settings below:
Open Watcher setting -> Scope , change it to Open Files
If you wanna more control over the plugin, you can have a look at the official doc
Instead of file watcher you can get External tools configured to achieve almost the same functionality. The only difference is that this won't run on save but rather you'll have to trigger this manually. Or you could configure a macro to run them on save (but I don't have experience with macros + external tools so I'm not if this will work).

Webpack sometimes fails to detect changes saved with Intellij Idea

I'm developing a JavaScript/React application in Intellij Idea and I'm using webpack-dev-server to incrementally build my files. That means that the dev server is watching the files and if a file gets changes, webpack rebuilds it. Pretty standard scenario.
Unfortunately, webpack sometimes decides to ignore certain files. I can change them all I want but webpack does nothing. I have not been able to determine any pattern on which files get ignored. It's arbitrary. Sometimes I just create a new file and webpack ignores it.
What is interesting though is that it only happens when I perform the save using Intellij Idea. If I open the file in another editor (for example vim) and save it, the file gets correctly rebuilt. Actually, simple touch file.js is enough to trigger rebuilding.
I guess there is something wrong in how Intellij Idea saves files. Any ideas?
This is due to an IDE feature known as "safe write". When enabled, the IDE will write the changes to a temporary file over the real one. This means webpack's file watching mechanism cannot pick up the changes. Disable this feature to fix the problem. Reference.
For me this did not work, I'm posting this in case anyone has the same scenario. After each save, webpack watch script builds the new bundles and I'm reloading all files from disk (CTRL + ALT + Y). Only after that the changes are visible.
There is an open issue "Background" changes by external tool not being picked up until VFS refresh happens regarding this behavior: file is saved but one has to reload all from disk in order to see the changes (for example in the browser).

How to automatically synchronize/refresh SCSS/CSS file on change?

Recently my client switched from Eclipse to Intellij. In both IDEs I was editing SCSS files externally and running "compass watch" in terminal. This worked great in Eclipse. immediately after compiling SCSS file I was able to simply refresh browser and see the changes.
In Intellij it takes up to 30 seconds to see the changes, or if I enable "synchronize files on frame activation" I have to switch to browser first, then back to Intellij, and then back again to browser in order to force refresh. Third option is to manually sync "css" folder, which is not convenient. I had a same issue when I was editing and compiling SCSS files in Intellij.
How can I force Intellij to detect CSS file change faster?
I've found the solution.
Open "Settings / File Watchers" and go to SCSS. Make sure that field "Output paths to refresh" has the same value for the output as "Arguments" field.
For example, this is my setup:
Arguments:
--no-cache --update $FileName$:$FileParentDir$\css\$FileNameWithoutExtension$.css
Output paths to refresh:
$FileParentDir$\css\$FileNameWithoutExtension$.css

How to automatically upload compiled coffeescript files in Intellij IDEA?

I use automatic deploy through FTP. Everything worked well until I started to use coffeescript and its filewatcher feature which recompiles my .coffee file into .js file on every change.
Problem is that IDEA don't want to upload these compiled files like others. So I have manually press hotkey to upload compiled file after every change, which I want to see on the server.
How can I do it more convenient to use?
There is an option to upload external changes automatically.
Right now IDEA will not perform synchronization after file watcher is invoked, so you will need to do File | Synchronize, IDE will detect the changes and upload them.
Next update will have an option for the file watcher to perform synchronization after execution as the result of addressing this feature request.
this feature request concerns to a possibility to synchronize all files in output directory on every change (required by some transpilers). But, AFAIK, this is not the case for CoffeeScript compiler - synchronization should work there. Do the generated js files appear in the Project View as soon as the compilation completes, or do you have to synchronize the view manually to see changes? In the latter case something must be wrong with file watcher configuration (output path set incorrectly, for example). If files are synchronized correctly, setting 'upload external changes' option should do the thing