Skip to content

Commit

Permalink
[feat] split Vite plugin in two (#7990)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Dec 8, 2022
1 parent 9b697d2 commit 89d1304
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-bikes-give.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[feat] split Vite plugin in two
18 changes: 13 additions & 5 deletions packages/kit/src/exports/vite/index.js
Expand Up @@ -61,7 +61,7 @@ const enforced_config = {

/** @return {import('vite').Plugin[]} */
export function sveltekit() {
return [...svelte(), kit()];
return [...svelte(), ...kit()];
}

/**
Expand All @@ -74,7 +74,7 @@ export function sveltekit() {
* - https://rollupjs.org/guide/en/#build-hooks
* - https://rollupjs.org/guide/en/#output-generation-hooks
*
* @return {import('vite').Plugin}
* @return {import('vite').Plugin[]}
*/
function kit() {
/** @type {import('types').ValidatedConfig} */
Expand Down Expand Up @@ -183,8 +183,9 @@ function kit() {
// TODO remove this for 1.0
check_vite_version();

return {
name: 'vite-plugin-svelte-kit',
/** @type {import('vite').Plugin} */
const plugin_build = {
name: 'vite-plugin-sveltekit-build',

/**
* Build the SvelteKit-provided Vite config to be merged with the user's vite.config.js file.
Expand Down Expand Up @@ -539,7 +540,12 @@ function kit() {
fs.unlinkSync(`${paths.output_dir}/client/${vite_config.build.manifest}`);
fs.unlinkSync(`${paths.output_dir}/server/${vite_config.build.manifest}`);
}
},
}
};

/** @type {import('vite').Plugin} */
const plugin_middleware = {
name: 'vite-plugin-sveltekit-middleware',

/**
* Adds the SvelteKit middleware to do SSR in dev mode.
Expand All @@ -557,6 +563,8 @@ function kit() {
return preview(vite, vite_config, svelte_config);
}
};

return [plugin_build, plugin_middleware];
}

function check_vite_version() {
Expand Down

0 comments on commit 89d1304

Please sign in to comment.