Skip to content

Commit

Permalink
[fix] change Vite's output directory from _app to client (#5620)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jul 19, 2022
1 parent ad09e6c commit 850528d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-cats-wonder.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] change Vite's output directory from `_app` to client
2 changes: 1 addition & 1 deletion packages/kit/src/vite/build/build_server.js
Expand Up @@ -73,7 +73,7 @@ export class Server {
manifest,
method_override: ${s(config.kit.methodOverride)},
paths: { base, assets },
prefix: assets + '/${config.kit.appDir}/',
prefix: assets + '/',
prerender: {
default: ${config.kit.prerender.default},
enabled: ${config.kit.prerender.enabled}
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/vite/build/build_service_worker.js
Expand Up @@ -43,7 +43,7 @@ export async function build_service_worker(
export const build = [
${Array.from(build)
.map((file) => `${s(`${config.kit.paths.base}/${config.kit.appDir}/${file}`)}`)
.map((file) => `${s(`${config.kit.paths.base}/${file}`)}`)
.join(',\n\t\t\t\t')}
];
Expand Down
8 changes: 4 additions & 4 deletions packages/kit/src/vite/build/utils.js
Expand Up @@ -101,9 +101,9 @@ export const get_default_config = function ({ config, input, ssr, outDir }) {
input,
output: {
format: 'esm',
entryFileNames: ssr ? '[name].js' : 'immutable/[name]-[hash].js',
chunkFileNames: 'immutable/chunks/[name]-[hash].js',
assetFileNames: 'immutable/assets/[name]-[hash][extname]'
entryFileNames: ssr ? '[name].js' : `${config.kit.appDir}/immutable/[name]-[hash].js`,
chunkFileNames: `${config.kit.appDir}/immutable/chunks/[name]-[hash].js`,
assetFileNames: `${config.kit.appDir}/immutable/assets/[name]-[hash][extname]`
},
preserveEntrySignatures: 'strict'
},
Expand Down Expand Up @@ -145,7 +145,7 @@ export function assets_base(config) {
// during `svelte-kit preview`, because we use a local asset path. This
// may be fixed in Vite 3: https://github.com/vitejs/vite/issues/2009
const { base, assets } = config.paths;
return `${assets || base}/${config.appDir}/`;
return `${assets || base}/`;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/kit/src/vite/index.js
Expand Up @@ -180,7 +180,7 @@ function kit() {
paths = {
build_dir: `${svelte_config.kit.outDir}/build`,
output_dir: `${svelte_config.kit.outDir}/output`,
client_out_dir: `${svelte_config.kit.outDir}/output/client/${svelte_config.kit.appDir}`
client_out_dir: `${svelte_config.kit.outDir}/output/client/`
};

if (is_build) {
Expand Down Expand Up @@ -271,7 +271,7 @@ function kit() {
});

fs.writeFileSync(
`${paths.client_out_dir}/version.json`,
`${paths.client_out_dir}/${svelte_config.kit.appDir}/version.json`,
JSON.stringify({ version: svelte_config.kit.version.name })
);

Expand Down Expand Up @@ -316,8 +316,8 @@ function kit() {

const files = new Set([
...static_files,
...chunks.map((chunk) => `${svelte_config.kit.appDir}/${chunk.fileName}`),
...assets.map((chunk) => `${svelte_config.kit.appDir}/${chunk.fileName}`)
...chunks.map((chunk) => chunk.fileName),
...assets.map((chunk) => chunk.fileName)
]);

// TODO is this right?
Expand Down

0 comments on commit 850528d

Please sign in to comment.