Trixrabbit
Trixrabbit
CDCloudflare Developers
Created by GoodGoodMan on 7/6/2023 in #pages-help
How can i use d1 locally(for test) on sveltekit?
I've decided to use nodemon to automate some stuff. These are my commands in package.json. I run both commands in 2 different terminals when doing local dev, first one builds, second one serves. The idea is to make the build + serve steps syncrhonous. To do that I monitor my /src folder for changes and build the app on change.Then I create a dummy file (in this case reload.trigger) when the build is done. Second, I monitor for the dummy file creation then trigger wrangler to serve my pages. Then delete the trigger file. (note I also make sure to kill workerd because of some weird port already in use error than wrangler gets into sometimes) Disclaimer: I haven't worked with this since the date of my post and it is possible wrangler does this better now
"build:watch": "nodemon --watch src -e ts,svelte --exec \"vite build; touch reload.trigger\"",
"wrangler": "nodemon -e trigger --exec \"pkill workerd; rm reload.trigger;export NO_D1_WARNING=true && wrangler pages dev .svelte-kit/cloudflare \"",
"build:watch": "nodemon --watch src -e ts,svelte --exec \"vite build; touch reload.trigger\"",
"wrangler": "nodemon -e trigger --exec \"pkill workerd; rm reload.trigger;export NO_D1_WARNING=true && wrangler pages dev .svelte-kit/cloudflare \"",
8 replies
CDCloudflare Developers
Created by GoodGoodMan on 7/6/2023 in #pages-help
How can i use d1 locally(for test) on sveltekit?
Are you ready for a janky solution 😛 Let me find what I ended up doing
8 replies
CDCloudflare Developers
Created by GoodGoodMan on 7/6/2023 in #pages-help
How can i use d1 locally(for test) on sveltekit?
Sorry for reviving this, but I've been trying for a couple days now to get this working and wrangler live-reload spits errors whenever vite rebuilds... it looks like wrangler reloads too fast and the files are not yet built. Did you experience this ?
8 replies