change pages functions watch directories in wrangler

When running pages functions locally wrangler watches only the functions directories. Is there a way to make it watch other directories too? [posted by mistake in Workers originally]
3 Replies
Aakash N S
Aakash N S•11mo ago
were you able to figure out a solution to this? From the source code of wrangler, it does look like it only watches the functions directory: https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/pages/dev.ts#L433 (thanks @pc) However, I was able to use chokidar-cli and concurrently to watch for changes in another source directory (called shared in my project), and touch one of the files inside functions to trigger a rebuild. Here's what the scripts sections of my package.json looks like:
"scripts": {
"wrangler": "npx wrangler@latest pages dev public",
"tailwind": "npx tailwindcss -i ./shared/styles.css -o ./public/styles.css --watch",
"chokidar": "npx chokidar-cli \"./shared/**/*.{js,jsx,ts,tsx}\" -c \"touch ./functions/ping.js\"",
"dev": "npx concurrently --handle-input --success first --kill-others --raw \"npm run chokidar\" \"npm run wrangler\" \"npm run tailwind\""
}
"scripts": {
"wrangler": "npx wrangler@latest pages dev public",
"tailwind": "npx tailwindcss -i ./shared/styles.css -o ./public/styles.css --watch",
"chokidar": "npx chokidar-cli \"./shared/**/*.{js,jsx,ts,tsx}\" -c \"touch ./functions/ping.js\"",
"dev": "npx concurrently --handle-input --success first --kill-others --raw \"npm run chokidar\" \"npm run wrangler\" \"npm run tailwind\""
}
NOTE: I'm also using Tailwind CSS to watch and rebuild styles.
Paolo of Lost Pages
Paolo of Lost PagesOP•11mo ago
I haven't. I just put the libraries in ./functions/libs and make sure they do not export onRequest*, so wrangler reloads when the files change
Aakash N S
Aakash N S•11mo ago
Thanks, I've done the same! Didn't realize that might work. 😅
Want results from more Discord servers?
Add your server