gregsullivan/_tw

What is 'npm run watch' supposed to do?

Debesyla opened this issue · 7 comments

Hey,

Total newbie question, as it's my first day using tailwind, this theme and npm-watch. I have followed the installation/setup instructions.

  • I have noticed that every time I change 'theme/theme.json' -> the theme/style.css successufully rebuilds itself ("Rebuilding..." -> "Done in..." in terminal);
  • But when I edit other files, like theme/index.php -> there is no automatic rebuild, nothing happens, the theme/style.css doesn't update. (The changes to the file are noticed and saved only if I call build command by hand. So the build process sees the files and the tw classes, it's just that watcher doesn't do anything.)

Is this intended way how it should work?

I haven't edited any setup files and I do see that in 'tailwind.config.js' the 'content' also includes './theme/**/*.php' line. I have expected that because of this the npm-watch would automatically rebuild styles after every .php file save. Was I wrong?

Sorry if it's stupid question, I haven't managed to google this out, haha... :))

Hello—Thanks for posting this issue!

Edits to PHP files should absolutely trigger another rebuild. I just generated a new theme from underscoretw.com, ran npm install and then npm run watch, and made a change to ./theme/index.php, which triggered a rebuild.

Can you confirm what version of npm you're using?

Right... It was v8.19.3, that came with node 18.13.0. I have updated node+npm to latest (19.5.0; 9.3.1) - but 'npm run watch' still doesn't detect changes to the .php files.

What else I could check and try?

What editor are you using to make changes?

Are you using a network mount or any sort of external storage?

You would try replacing --watch with --poll here to see what happens:

_tw/package.json

Lines 33 to 34 in 5dc2806

"watch:tailwind:frontend": "npm run development:tailwind:frontend -- --watch",
"watch:tailwind:editor": "npm run development:tailwind:editor -- --watch",

(This way Tailwind will check on a recurring basis rather than wait for filesystem events.)

Finally, I'd be curious whether changes to ./javascript/script.js trigger esbuild to rebuild.

Hope some of that helps!

  • Using VSCode.
  • Uh... I can't understand your question - I just have the folder with files locally on my PC folder, those then don't sync anywhere 🤷🏼‍♂️
  • Tried it with --poll, I'm not sure what the reccuring basis is, but nothing happens in 5 minutes after changes too 😄
  • Rebuild does trigger on every ./javascript/script.js change, yes!

I have tried to disable every VSCode extension and resetting all settings - but that didn't help either. Strange...

That definitely answers the question! My understanding is that --watch doesn't work if you're using a network drive of some form or another, so I wanted to confirm that wasn't the case. (Are you using Windows Subsystem for Linux? Apparently that can cause problems, too.)

The recurring basis is very short—less than a second—so it definitely should have updated in less than five minutes!

I've heard that security software can sometimes interfere with the Tailwind CLI's watch functionality, as another possibility.

Here's a comment in another issue that feels promising:

tailwindlabs/tailwindcss#7590 (comment)

Since only the content item with the ** glob is failing, I think there might be other characters in the full path causing glob parsing to fail. You could confirm by changing ./theme/**/*.php to ./theme/*.php to see if that helps. (This doesn't actually fix your problem, as only PHP files in the root directory would trigger a rebuild.) You could then try moving your project to a path without spaces, parentheses, or other unusual characters to see whether that helps.

(Reading through that issue might give you some other options to try.)

Oh god. It was indeed a parenthesis problem as I had two folders up named with parenthesis... Crazy, I would have never guessed that this could be a problem 😄 Issue is "solved" then, I will just rename my folder, haha. Thank you!

You're very welcome—happy to hear this resolved the issue!