How to use --persist-to flag when starting local FE with e.g., vite dev?

I have a monorepo where a number of packages share the same D1, KV, etc. For local DX it would be great to be able to create one local version and reuse it across all packages. This is achievable when starting local Workers etc by appending the --persist-to ../path/here flag to wrangler dev. Is there an equivalent way to point my frontend to the persisted resource? I.e., start the SvelteKit dev server (via vite dev) and have it use the persisted resource instead of create another .wrangler/ directory in the FE directory
2 Replies
stibbs
stibbsOP•2w ago
Reading through this post from April 2024 Blazing fast development with full stack frameworks and Cloudflare makes me think there might be a way via getPlatformProxy which can accept an argument like persist: "./my-directory/v3". However I can't see how to actually make use of this knowledge 😅
stibbs
stibbsOP•2w ago
You can set the options for getPlatformProxy in adapter-cloudflare Remember to append /v3 to the adapter persist path because getPlatformProxy does not add that by default, whereas wrangler --persist-to does
// svelte.config.ts
import adapter from "@sveltejs/adapter-cloudflare";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";

const config = {
preprocess: vitePreprocess(),

kit: {
adapter: adapter({
platformProxy: {
persist: {path: "../path/here/v3"},
},
}),
},
};

export default config;
// svelte.config.ts
import adapter from "@sveltejs/adapter-cloudflare";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";

const config = {
preprocess: vitePreprocess(),

kit: {
adapter: adapter({
platformProxy: {
persist: {path: "../path/here/v3"},
},
}),
},
};

export default config;
Cloudflare Pages • Docs • Svelte
Cloudflare Pages • Svelte documentation
Want results from more Discord servers?
Add your server