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: do not copy vite manifest instead of removing during build #10782

Merged
merged 11 commits into from
Sep 26, 2023
5 changes: 5 additions & 0 deletions .changeset/young-wolves-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: only remove Vite manifest when copying files
5 changes: 4 additions & 1 deletion packages/kit/src/core/adapt/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ export function create_builder({
},

writeClient(dest) {
return copy(`${config.kit.outDir}/output/client`, dest);
return copy(`${config.kit.outDir}/output/client`, dest, {
// avoid making vite build artefacts public
filter: (basename) => basename !== '.vite'
});
},

writePrerendered(dest) {
Expand Down
4 changes: 3 additions & 1 deletion packages/kit/src/core/adapt/builder.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ test('copy files', () => {
rmSync(dest, { recursive: true, force: true });

expect(builder.writeClient(dest)).toEqual(list_files(dest).map(posixify));
expect(list_files(`${outDir}/output/client`)).toEqual(list_files(dest));
expect(
list_files(`${outDir}/output/client`).filter((file) => !file.startsWith('.vite/'))
).toEqual(list_files(dest));

rmSync(dest, { recursive: true, force: true });

Expand Down
6 changes: 1 addition & 5 deletions packages/kit/src/exports/vite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ function kit({ svelte_config }) {
cssCodeSplit: true,
cssMinify: initial_config.build?.minify == null ? true : !!initial_config.build.minify,
// don't use the default name to avoid collisions with 'static/manifest.json'
manifest: 'vite-manifest.json',
manifest: '.vite/manifest.json', // TODO: remove this after bumping peer dep to vite 5
outDir: `${out}/${ssr ? 'server' : 'client'}`,
rollupOptions: {
input,
Expand Down Expand Up @@ -805,10 +805,6 @@ function kit({ svelte_config }) {
.cyan('npm run preview')} to preview your production build locally.`
);

// avoid making the manifest available to users
fs.unlinkSync(`${out}/client/${vite_config.build.manifest}`);
fs.unlinkSync(`${out}/server/${vite_config.build.manifest}`);

if (kit.adapter) {
const { adapt } = await import('../../core/adapt/index.js');
await adapt(svelte_config, build_data, metadata, prerendered, prerender_map, log);
Expand Down
Loading