Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unused SSR CSS files #10686

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-drinks-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: remove unused SSR CSS assets
18 changes: 14 additions & 4 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,20 @@ function kit({ svelte_config }) {
})
);

copy(
`${out}/server/${kit.appDir}/immutable/assets`,
`${out}/client/${kit.appDir}/immutable/assets`
);
// don't copy unused CSS generated by Vite's build.ssrEmitAssets option
const server_css = Object.values(server_manifest)
.filter((entry) => entry.css)
.map((entry) => entry.css)
.flat();

const assets_path = `${kit.appDir}/immutable/assets`;

copy(`${out}/server/${assets_path}`, `${out}/client/${assets_path}`, {
filter: (basename) => {
const filepath = `${assets_path}/${basename}`;
return !server_css.includes(filepath);
}
});

/** @type {import('vite').Manifest} */
const client_manifest = JSON.parse(read(`${out}/client/${vite_config.build.manifest}`));
Expand Down
Loading