From 31273df56225b2332ff841ca4fdec1f9a956031e Mon Sep 17 00:00:00 2001 From: Richard O'flynn Date: Thu, 27 Jan 2022 11:45:57 +0000 Subject: [PATCH 1/4] Support an async function to provide vite config --- packages/kit/src/core/dev/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kit/src/core/dev/index.js b/packages/kit/src/core/dev/index.js index a1e9a948e20b..b28978c0544e 100644 --- a/packages/kit/src/core/dev/index.js +++ b/packages/kit/src/core/dev/index.js @@ -41,7 +41,7 @@ export async function dev({ cwd, port, host, https, config }) { strictPort: true } }, - config.kit.vite() + await config.kit.vite() ); /** @type {[any, string[]]} */ From 915b94349d6dac64cea2d35e38ffe9c03d3601a4 Mon Sep 17 00:00:00 2001 From: Richard O'flynn Date: Thu, 27 Jan 2022 12:03:47 +0000 Subject: [PATCH 2/4] amend all instances of config.kit.vite --- packages/kit/src/core/build/build_client.js | 2 +- packages/kit/src/core/build/build_server.js | 2 +- packages/kit/src/core/build/build_service_worker.js | 2 +- packages/kit/src/core/preview/index.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/kit/src/core/build/build_client.js b/packages/kit/src/core/build/build_client.js index b7198f1fd51e..fb36f76d45b0 100644 --- a/packages/kit/src/core/build/build_client.js +++ b/packages/kit/src/core/build/build_client.js @@ -60,7 +60,7 @@ export async function build_client({ }); /** @type {[any, string[]]} */ - const [merged_config, conflicts] = deep_merge(config.kit.vite(), { + const [merged_config, conflicts] = deep_merge(await config.kit.vite(), { configFile: false, root: cwd, base: assets_base, diff --git a/packages/kit/src/core/build/build_server.js b/packages/kit/src/core/build/build_server.js index be3423eb700a..ddf333da29e0 100644 --- a/packages/kit/src/core/build/build_server.js +++ b/packages/kit/src/core/build/build_server.js @@ -181,7 +181,7 @@ export async function build_server( ); /** @type {import('vite').UserConfig} */ - const vite_config = config.kit.vite(); + const vite_config = await config.kit.vite(); const default_config = { build: { diff --git a/packages/kit/src/core/build/build_service_worker.js b/packages/kit/src/core/build/build_service_worker.js index adf4d1a51982..e4779a0599e4 100644 --- a/packages/kit/src/core/build/build_service_worker.js +++ b/packages/kit/src/core/build/build_service_worker.js @@ -56,7 +56,7 @@ export async function build_service_worker( ); /** @type {[any, string[]]} */ - const [merged_config, conflicts] = deep_merge(config.kit.vite(), { + const [merged_config, conflicts] = deep_merge(await config.kit.vite(), { configFile: false, root: cwd, base: assets_base, diff --git a/packages/kit/src/core/preview/index.js b/packages/kit/src/core/preview/index.js index f694665eee92..fa05df2662c5 100644 --- a/packages/kit/src/core/preview/index.js +++ b/packages/kit/src/core/preview/index.js @@ -69,7 +69,7 @@ export async function preview({ const app = new App(manifest); /** @type {import('vite').UserConfig} */ - const vite_config = (config.kit.vite && config.kit.vite()) || {}; + const vite_config = (config.kit.vite && await config.kit.vite()) || {}; const server = await get_server(use_https, vite_config, (req, res) => { if (req.url == null) { From e3986c72d7cc055c617a780e35e3a66d3fc65888 Mon Sep 17 00:00:00 2001 From: Richard O'flynn Date: Thu, 27 Jan 2022 13:14:52 +0000 Subject: [PATCH 3/4] run pnpm format --- packages/kit/src/core/preview/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kit/src/core/preview/index.js b/packages/kit/src/core/preview/index.js index fa05df2662c5..34c3d6a286f6 100644 --- a/packages/kit/src/core/preview/index.js +++ b/packages/kit/src/core/preview/index.js @@ -69,7 +69,7 @@ export async function preview({ const app = new App(manifest); /** @type {import('vite').UserConfig} */ - const vite_config = (config.kit.vite && await config.kit.vite()) || {}; + const vite_config = (config.kit.vite && (await config.kit.vite())) || {}; const server = await get_server(use_https, vite_config, (req, res) => { if (req.url == null) { From 50152f80f4a12e404d00105eae953a4295756dd4 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 1 Feb 2022 09:03:16 -0500 Subject: [PATCH 4/4] changeset --- .changeset/sour-shirts-camp.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sour-shirts-camp.md diff --git a/.changeset/sour-shirts-camp.md b/.changeset/sour-shirts-camp.md new file mode 100644 index 000000000000..8bdc5a6c27fa --- /dev/null +++ b/.changeset/sour-shirts-camp.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Allow config.kit.vite to be an async function