diff --git a/packages/kit/src/core/config/options.js b/packages/kit/src/core/config/options.js index 1d8d4cbc554c..9832dac88878 100644 --- a/packages/kit/src/core/config/options.js +++ b/packages/kit/src/core/config/options.js @@ -270,7 +270,9 @@ const options = object( version: object({ name: string(Date.now().toString()), pollInterval: number(0) - }) + }), + + devPlatform: object({}, true), }) }, true diff --git a/packages/kit/src/exports/public.d.ts b/packages/kit/src/exports/public.d.ts index 6b21eaae8e46..7d1f1e655b56 100644 --- a/packages/kit/src/exports/public.d.ts +++ b/packages/kit/src/exports/public.d.ts @@ -657,6 +657,12 @@ export interface KitConfig { */ pollInterval?: number; }; + /** + * Platform object to be used during development, allowing the simulation of a production platform during local development. + * + * @default undefined + */ + devPlatform?: unknown; } /** diff --git a/packages/kit/src/exports/vite/dev/index.js b/packages/kit/src/exports/vite/dev/index.js index cfe846dbe326..0caef402361c 100644 --- a/packages/kit/src/exports/vite/dev/index.js +++ b/packages/kit/src/exports/vite/dev/index.js @@ -529,7 +529,8 @@ export async function dev(vite, vite_config, svelte_config) { read: (file) => fs.readFileSync(path.join(svelte_config.kit.files.assets, file)), before_handle: (event, config, prerender) => { async_local_storage.enterWith({ event, config, prerender }); - } + }, + platform: svelte_config.kit.devPlatform, }); if (rendered.status === 404) { diff --git a/packages/kit/src/exports/vite/preview/index.js b/packages/kit/src/exports/vite/preview/index.js index c34af3121e1d..1247337eff5b 100644 --- a/packages/kit/src/exports/vite/preview/index.js +++ b/packages/kit/src/exports/vite/preview/index.js @@ -191,7 +191,8 @@ export async function preview(vite, vite_config, svelte_config) { if (remoteAddress) return remoteAddress; throw new Error('Could not determine clientAddress'); }, - read: (file) => fs.readFileSync(join(svelte_config.kit.files.assets, file)) + read: (file) => fs.readFileSync(join(svelte_config.kit.files.assets, file)), + platform: svelte_config.kit.devPlatform, }) ); }); diff --git a/packages/kit/types/index.d.ts b/packages/kit/types/index.d.ts index 231e2ea8ee23..fbc1bb981689 100644 --- a/packages/kit/types/index.d.ts +++ b/packages/kit/types/index.d.ts @@ -639,6 +639,12 @@ declare module '@sveltejs/kit' { */ pollInterval?: number; }; + /** + * Platform object to be used during development, allowing the simulation of a production platform during local development. + * + * @default undefined + */ + devPlatform?: unknown; } /**