CLI watch mode not working correctly when using visual studio
See original GitHub issueWhat version of Tailwind CSS are you using?
TailwindCSS CLI: v3.2.1 Visual Studio: 2022 - Version 17.3.6
What build tool (or framework if it abstracts the build tool) are you using?
Visual Studio
What operating system are you using?
Windows 10
Describe your issue
the tailwind cli in watcher mode: tailwind.exe -i ./Styles/site.css -o ./wwwroot/css/site.css --watch --verbose edit a .razor or cshtml file with Notepad++ and save the file - the watcher sees the change and rebuilds correctly
but when i open visual studio and edit the exact same file in vstudio, and save the file, nothing happens. as you can see on the screenshot, notepad++ detects there is a change, but the tailwind cli tool does not
config:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./**/*.{razor,html,cshtml}"],
theme: {
extend: {},
},
plugins: [],
}
i then made a copy of a cshtml file in windows explorer, and noticed the watcher is not reacting on the new file as well. only when i restart the cli tool, edits in the new file trigger a rebuild. this made me investigate some more:
changing the configuration to
content: ["./Pages/*.*"],
and saving a .razor page in visual studio in this folder leads to this crash:
looks like visual studio is saving files via a temp file, and then renames it. this way the cli watcher doesn’t see it anymore. is this possible to fix? or is this just happening on my computer? 😃
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:9
EDIT: I stepped back through each release, this appears to have started in 3.1.8.
I’m experiencing similar behavior.
From what I’m observing, if Visual Studio is used to edit any source file during a Tailwind CSS watcher session, the watcher does not rebuild in response to that change, and becomes oblivious to all subsequent changes, whether they took place in Visual Studio, Notepad++, or whatever (however – in my case, even using the --verbose option, Tailwind CSS does not display any indication of an exception).
If you then terminate and re-start Tailwind CSS, the watcher’s behavior returns to normal (rebuilding in response to changes made in Notepad++, for example), until Visual Studio is used to make another change.
Edit: @tecxx if this is a different problem than what you’re experiencing, let me know and I’ll move this to a new issue.
Hey all, I merged a PR by @natrys that should fix these problems. If you could give the latest insiders build a test and report back here it would be much appreciated:
npm install tailwindcss@insiders
I’ve done some testing on my own and it appears that Visual Studio on Windows is finally working again and VIM on Linux (and WSL even) when it performs backups for saves.
Note: that WSL fs events are effectively broken under
/mnt/{a,b,c,d,…}
so you have to use--poll
or be in a different, non-shared mount.Gonna close as we believe the issue has been fixed but will re-open if there turns out to be more things we need to address w/ regards to the CLI watching.