How to "auto reload" file after external changes

Just purchased PhpStorm (coming from vs code) and i'm running into a pretty annoying issue.

On a project i have a webpack setup with some stylelint plugins that reorder some properties in a logical way after a save (see stylelint config below)

extends: [
'stylelint-config-standard',
'stylelint-config-standard-scss',
'stylelint-config-rational-order',
'stylelint-prettier/recommended',
],

While in VsCode the file was automagicly reloaded in the editor PhpStorm is throwing up the following message,

https://cln.sh/i0URf1pa7JDf280iQnDh 

Any suggestions on how to fix this? I tried a file watcher but other than "the watcher is disabled because of reason x, y, z" didn't bring me any luck. 

0
14 comments

this dialog indicates that the file is being modified concurrently - from within the IDE and externally

If the external tool is set up as a file watcher and the Output paths for refresh is configured so that the IDE knows what files are modified and synchronizes its virtual file system when the execution completes, no such issues should occur.

0

Any suggestions on a clean instruction how to set up a file watcher? Because what i'm having now takes ages to run compared to just running ```npm run dev``` from a VSCode terminal window and let Webpack do it's work.

https://cln.sh/D96d9GCvRHICGyI1xxgd 

Probably i'm doing something wrong here but i can't find any clear instructions on HOW this should work.

0

No idea. Did you set up Output paths for refresh? Also, I'd suggest reducing the watchers scope - I don't think you need it being started on any change made to any file...

0

I changed it a bit but i'm still not happy with the performance compared to what i had in VS Code.

It takes pretty long before PhpStorm is picking up the changes that Stylelint (order of properties) made to the scss files.

If anyone has a suggestion on how to speed this up (PhpStorm doesn't have to do anything... webpack does everything, it only needs to reload a file when it has been changed... how hard can it be you would think). With the above i have the idea that webpack is doing things twice, once from the terminal i have it running on but also from PhpStorm with the settings above.

 

0

>It takes pretty long before PhpStorm is picking up the changes that Stylelint (order of properties) made to the scss files.

Most probably the Output paths for refresh is not set up properly so the virtual file system is not refreshed once the build completes

0

And the "most likely solution" would be? Maybe i'm just being stupid but is there any documentation on HOW this should work and get it performing properly with a pretty common build tool like Webpack? The only thing PhpStorm has to do is detect a file change and refresh the file, every simple editor out there does that without issues, VS Code, Sublime text, Atom even Coda that hasn't been updated for ages does it. 

0

the Output paths for refresh is supposed to tell the IDE what files have to be refreshed; Output paths are usually specified using macros, like $FilePathRelativeToProjectRoot$

There are no specific instructions for webpack, as the command and output are specific to the build configuration (plus webpack is not a tool that is typically set up as a file watcher)

0

plus webpack is not a tool that is typically set up as a file watcher

Not sure which projects i have been working on then for the last few years then but every project i have been working on used webpack as a file watcher to re-compile stuff on changes... it's a core feature of webpack, https://webpack.js.org/configuration/watch/

Just a simple file watch (i made a screen recording, every time PhpStorm is detecting changes i could take a lunch break and still have time left to do grocery shopping), VS code vs PhpStorm, https://cln.sh/w5I3CXAynZ2AXi9xmpBx

0

It takes pretty long before PhpStorm is picking up the changes that Stylelint (order of properties) made to the scss files

If you take focus to another window it reloads the file directly after compiling, however with 2 4K screens there isn't any reason why i should tab to another window to check my changes. Long story short, it definitely didn't work for me so i got back to Visual Studio code which does this instantly and doesn't need a file watcher.

1

The IDE doesn't automatically synchronize its virtual file system on changes made externally. We have a request to change this,  https://youtrack.jetbrains.com/issue/IDEA-168617. No plans regarding implementing it in the nearest releases:(.
The main concern of implementing this is that IDE may freeze in unpredictable moments and spent unpredictable time while synchronizing files with changes made externally.
you can use File > Reload all from disk when your file is changed externally to get it updated in the IDE

1

Hi Elena Pogorelova, I have a different use case, but the same problem. I'm using a charting library that outputs a chart as a static HTML file. I want to open (preview) that chart in a browser and use IntelliJ's "Reload on save" feature so that when I re-run my code and an updated chart (html file) is produced, the browser updates (I'm doing 'exploratory data analysis', not building an application).

Current behaviour almost works, except that I have to tab out of and back into IntelliJ for it to register the filesystem change and update the browser (or manually select File > Reload all from disk).

Is there any way to tell IntelliJ to "watch for external changes of files in scope X"? (I assume 'file watchers' have to actually perform some action, not just watch and update, so can't be used for this).

Or even better, if I choose to open an html file and have it set to 'reload on save', then IntelliJ automatically watches for external changes of that specific file. Is this possible?

0

>Is there any way to tell IntelliJ to "watch for external changes of files in scope X"? (I assume 'file watchers' have to actually perform some action, not just watch and update, so can't be used for this)

 

No way. You can create a dummy file watcher that does almost nothing (run an empty shell script, for example) and set up the output paths to refresh so that the the generated file is watched for changes

0

IM here because phpstorm just doesnt refresh any file changes at all done outside the editor. Sometimes takes 10 if the file edited externally is the one your currently looking at. Its really bad. Folders in the project tree not showing any new files.

With AI tools making modifications via terminal its a real problem.

1

Hi Bradozman,

This thread is quite old. I suggest submitting a new request to support directly from the IDE via Help > Contact Support for further assistance.

0

Please sign in to leave a comment.