workers-sdk
workers-sdk copied to clipboard
feature request: vite plugin with sveltekit
Which Cloudflare product(s) does this pertain to?
Vite Plugin
What versions & operating system are you using?
macOS
Please provide a link to a minimal reproduction
No response
Describe the Bug
I am trying to access a D1 database defined in my wrangler.jsonc. The documentation for the svelte plugin make it seem as though it should just work but I don't see a database in my hooks.server.ts.
import type { Handle } from "@sveltejs/kit";
import { DB } from '$env/static/private';
export const handle: Handle = async ({ event, resolve }) => {
// all undefined
console.log(process.env.DB, import.meta.env.DB, DB);
}
svelte config
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://svelte.dev/docs/kit/integrations
// for more information about preprocessors
preprocess: vitePreprocess(),
};
export default config;
vite config
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import { cloudflare } from "@cloudflare/vite-plugin";
export default defineConfig({
plugins: [sveltekit(), cloudflare()]
});
Please provide any relevant error logs
No response
It works with the adapter but I thought the idea of the Vite plugin is that I don't need an adapter anymore.
import adapter from "@sveltejs/adapter-cloudflare";
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://svelte.dev/docs/kit/integrations
// for more information about preprocessors
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
};
export default config;
Hey the vite plugin does not work with sveltekit yet, but we're working on it with the svelte team :)
Ah ok, thanks for clarifying. I'll use the adapter for now then.
Hey the vite plugin does not work with sveltekit yet, but we're working on it with the svelte team :)
Thanks for the info, would you be able to hazard an ETA?
My day would be made if this ships <3
Using the adapter for development introduces a delay every time we save the files for rebuilding. It would be great if the vite plugin works so we get HMR.
I would love to see support, because it currently makes stuff very difficult to use multiple workers.
Still waiting on this :(
@zemjr there's quite a lot of places this is talked about - not really a single place to track it but here's the latest update AFAIK
we’re waiting until SvelteKit 3 before we move to the environment API
Originally posted in https://github.com/sveltejs/kit/issues/14008#issuecomment-3567568069