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

[feat] split Vite plugin in two #7990

Merged
merged 4 commits into from
Dec 8, 2022
Merged
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/seven-bikes-give.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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