@@ -1232,7 +1232,7 @@ function kit({ svelte_config }) {
12321232 let new_config ;
12331233
12341234 if ( is_build ) {
1235- const prefix = `${ kit . appDir } /immutable` ;
1235+ const app_immutable = `${ kit . appDir } /immutable` ;
12361236
12371237 /** @type {Record<string, string> } */
12381238 const server_input = {
@@ -1313,9 +1313,9 @@ function kit({ svelte_config }) {
13131313
13141314 /** @type {string } */
13151315 const base = ( kit . paths . assets || kit . paths . base ) + '/' ;
1316- const root_to_assets = prefix + '/assets/' ;
1316+ const root_to_assets = app_immutable + '/assets/' ;
13171317 const assets_to_root =
1318- prefix
1318+ app_immutable
13191319 . split ( '/' )
13201320 . map ( ( ) => '..' )
13211321 . join ( '/' ) + '/../' ;
@@ -1338,7 +1338,7 @@ function kit({ svelte_config }) {
13381338 rolldownOptions : {
13391339 output : {
13401340 name : `__sveltekit_${ version_hash } .app` ,
1341- assetFileNames : `${ prefix } /assets/[name].[hash][extname]` ,
1341+ assetFileNames : `${ app_immutable } /assets/[name].[hash][extname]` ,
13421342 hoistTransitiveImports : false ,
13431343 sourcemapIgnoreList
13441344 } ,
@@ -1391,8 +1391,8 @@ function kit({ svelte_config }) {
13911391 input : inline ? client_input [ 'bundle' ] : client_input ,
13921392 output : {
13931393 format : inline ? 'iife' : 'esm' ,
1394- entryFileNames : `${ prefix } /[name].[hash].js` ,
1395- chunkFileNames : `${ prefix } /chunks/[hash].js` ,
1394+ entryFileNames : `${ app_immutable } /[name].[hash].js` ,
1395+ chunkFileNames : `${ app_immutable } /chunks/[hash].js` ,
13961396 codeSplitting :
13971397 svelte_config . kit . output . bundleStrategy === 'split' ? undefined : false
13981398 } ,
@@ -1428,6 +1428,11 @@ function kit({ svelte_config }) {
14281428 return { relative } ;
14291429 }
14301430
1431+ if ( ! relative ) return ;
1432+
1433+ // ensure assets loaded by CSS files are loaded relative to the
1434+ // CSS file rather than the default of relative to the root
1435+
14311436 // _app/immutable/assets files
14321437 if ( filename . startsWith ( root_to_assets ) ) {
14331438 return `./${ filename . slice ( root_to_assets . length ) } ` ;
0 commit comments