@@ -286,6 +286,20 @@ export async function dev(vite, vite_config, svelte_config, illegal_imports) {
286
286
}
287
287
} ) ;
288
288
289
+ const runtime_base = runtime_directory . startsWith ( process . cwd ( ) )
290
+ ? `/${ path . relative ( '.' , runtime_directory ) } `
291
+ : `/@fs${
292
+ // Windows/Linux separation - Windows starts with a drive letter, we need a / in front there
293
+ runtime_directory . startsWith ( '/' ) ? '' : '/'
294
+ } ${ runtime_directory } `;
295
+
296
+ const { set_private_env } = await vite . ssrLoadModule ( `${ runtime_base } /env-private.js` ) ;
297
+ const { set_public_env } = await vite . ssrLoadModule ( `${ runtime_base } /env-public.js` ) ;
298
+
299
+ const env = get_env ( vite_config . mode , svelte_config . kit . env . publicPrefix ) ;
300
+ set_private_env ( env . private ) ;
301
+ set_public_env ( env . public ) ;
302
+
289
303
return ( ) => {
290
304
const serve_static_middleware = vite . middlewares . stack . find (
291
305
( middleware ) =>
@@ -320,20 +334,6 @@ export async function dev(vite, vite_config, svelte_config, illegal_imports) {
320
334
) ;
321
335
}
322
336
323
- // For some reason using runtime_prefix here is buggy, since Vite will later load the modules
324
- // again with a slightly different url (with the drive letter) on windows
325
- const runtime_base = `/@fs${
326
- // Windows/Linux separation - Windows starts with a drive letter, we need a / in front there
327
- runtime_directory . startsWith ( '/' ) ? '' : '/'
328
- } ${ runtime_directory } `;
329
-
330
- const { set_private_env } = await vite . ssrLoadModule ( `${ runtime_base } /env-private.js` ) ;
331
- const { set_public_env } = await vite . ssrLoadModule ( `${ runtime_base } /env-public.js` ) ;
332
-
333
- const env = get_env ( vite_config . mode , svelte_config . kit . env . publicPrefix ) ;
334
- set_private_env ( env . private ) ;
335
- set_public_env ( env . public ) ;
336
-
337
337
/** @type {Partial<import('types').Hooks> } */
338
338
const user_hooks = resolve_entry ( svelte_config . kit . files . hooks )
339
339
? await vite . ssrLoadModule ( `/${ svelte_config . kit . files . hooks } ` )
0 commit comments