remix: [Bug]: live reload rebuild twice when using tailwind watch

Which Remix packages are impacted?

  • remix (Remix core)
  • create-remix
  • @remix-run/architect
  • @remix-run/cloudflare-workers
  • @remix-run/dev
  • @remix-run/express
  • @remix-run/netlify
  • @remix-run/node
  • @remix-run/react
  • @remix-run/serve
  • @remix-run/server-runtime
  • @remix-run/vercel

What version of Remix are you using?

1.0.6

Steps to Reproduce

Follow the styling section for tailwindcss in remix doc

Expected Behavior

live reload ignore the generated css file change

Actual Behavior

[1] šŸ’æ File changed: app/styles/app.css [1] šŸ’æ Rebuilding… [1] šŸ’æ Rebuilt in 226ms [1] GET /form 200 - - 31.452 ms [1] šŸ’æ File changed: app/styles/app.css [1] šŸ’æ Rebuilding… [1] šŸ’æ Rebuilt in 170ms

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 27 (12 by maintainers)

Most upvoted comments

My PR was merged into postcss-cli!

If you update your version to 9.1.0 or greater you should no longer get a double-refresh when you save a file unless you actually do change the CSS (like in the Tailwind JIT case, if you change the class name on an element). In that case you’ll still get the double-reload. @ryanflorence had some ideas of how to avoid that once and for all. But the nice this is with postcss-cli 9.1.0 you’ll no longer get an unnecessary rebuild 😃

Instead of adding a workaround to Remix, it could also be an option to try to get postcss to not write files if their content didn’t change (there is also existing issue for that https://github.com/postcss/postcss-cli/issues/320).

Thanks for this awesome improvement @kentcdodds !

That issue isn’t quite what we need. That issue just says: ā€œif the input is the same as the output then don’t save the fileā€ but what we need is ā€œif the output is the same as what’s currently in the output then don’t save the file.ā€ In any case, I’m going to look into implementing what we need.

It should now be fixed for Tailwind CLI. I’ll try again in the next 24 hours (when I can access my laptop). And if it works, I guess we could close the issue.

@edgesoft thanks! It works