Skip to content

feature request: vite plugin with sveltekit #8922

Description

@domoritz

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package:vite-pluginRelating to the `@cloudflare/vite-plugin` package

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions