File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
packages/kit/src/exports/vite Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @sveltejs/kit ' : patch
3
+ ---
4
+
5
+ fix: avoid copying SSR stylesheets to client assets
Original file line number Diff line number Diff line change @@ -1064,11 +1064,25 @@ async function kit({ svelte_config }) {
1064
1064
throw stackless ( error . stack ?? error . message ) ;
1065
1065
}
1066
1066
1067
- copy (
1068
- `${ out } /server/${ kit . appDir } /immutable/assets` ,
1069
- `${ out } /client/${ kit . appDir } /immutable/assets`
1067
+ // We use `build.ssrEmitAssets` so that asset URLs created from
1068
+ // imports in server-only modules correspond to files in the build,
1069
+ // but we don't want to copy over CSS imports as these are already
1070
+ // accounted for in the client bundle. In most cases it would be
1071
+ // a no-op, but for SSR builds `url(...)` paths are handled
1072
+ // differently (relative for client, absolute for server)
1073
+ // resulting in different hashes, and thus duplication
1074
+ const ssr_stylesheets = new Set (
1075
+ Object . values ( server_manifest )
1076
+ . map ( ( chunk ) => chunk . css ?? [ ] )
1077
+ . flat ( )
1070
1078
) ;
1071
1079
1080
+ const assets_path = `${ kit . appDir } /immutable/assets` ;
1081
+
1082
+ copy ( `${ out } /server/${ assets_path } ` , `${ out } /client/${ assets_path } ` , {
1083
+ filter : ( basename ) => ! ssr_stylesheets . has ( `${ assets_path } /${ basename } ` )
1084
+ } ) ;
1085
+
1072
1086
/** @type {import('vite').Manifest } */
1073
1087
const client_manifest = JSON . parse ( read ( `${ out } /client/.vite/manifest.json` ) ) ;
1074
1088
You can’t perform that action at this time.
0 commit comments