workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

🐛 BUG: `wrangler pages dev` `--live-reload` does not watch static assets

Open malobre opened this issue 1 year ago • 9 comments

Which Cloudflare product(s) does this pertain to?

Wrangler core, Miniflare

What version(s) of the tool(s) are you using?

[email protected], [email protected]

What version of Node are you using?

21.7.0

What operating system and version are you using?

Linux 6.8.1 (arch linux)

Describe the Bug

Observed behavior

Editing a file served by the pages dev server does not trigger a page reload.

Expected behavior

Page reload on file update.

Steps to reproduce

  • create a file (in my case a simple index.html)
  • start pages dev server wrangler pages dev --live-reload [directory]
  • edit the file

misc

There are comments on the original PR adding the live reload feature mentioning that users are unable to get it to work: #220

Potentially related to #4124 ?

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No errors in browser console or wrangler logs

malobre avatar Mar 21 '24 22:03 malobre

After a little investigation wrangler seems to only watch files in the functions dir, e.g: with wrangler pages dev --live-reload dist:

  • touch dist/my-page.html doesn't reload /my-page
  • touch functions/my-page.ts does reload /my-page

malobre avatar Apr 17 '24 14:04 malobre

That would explain this one too: https://github.com/cloudflare/workers-sdk/issues/4824

treeder avatar Apr 17 '24 15:04 treeder

Yes, this is surely related, if not a duplicate.

malobre avatar Apr 17 '24 20:04 malobre

Hi @malobre, thank you for reporting this issue.

You are indeed correct in saying that pages dev does not watch for static assets changes. It currently watches for:

  • /functions directory
  • _worker.js file/directory
  • _routes.json

Triaging this issue and will discuss it as part of the pages dev improvements milestone

CarmenPopoviciu avatar Apr 24 '24 12:04 CarmenPopoviciu

this, combined with --live-reload reloading before some build processes finish, makes that feature barely usable

Hades32 avatar Aug 14 '24 13:08 Hades32

Are there any updates on this? It's a major blocker for smooth development in local environments.

serban-mihai avatar Dec 21 '24 14:12 serban-mihai

what I've done is run another server&builder, using wrangler only for cloudflare related functions, in my case I use esbuild

zugdev avatar Dec 21 '24 17:12 zugdev

what I've done is run another server&builder, using wrangler only for cloudflare related functions, in my case I use esbuild

I know there are endless combinations of services that could be applied to Pages in such a scenario, but if you could provide an example that would be much appreciated.

serban-mihai avatar Dec 21 '24 18:12 serban-mihai