Skip to content

Commit

Permalink
fix: move Vite file removal to adapter methods (#10782)
Browse files Browse the repository at this point in the history
  • Loading branch information
eltigerchino authored Sep 26, 2023
1 parent b30cb40 commit 4b32c5b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
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

0 comments on commit 4b32c5b

Please sign in to comment.