Skip to content

Commit

Permalink
Support an async function to provide vite config (#3565)
Browse files Browse the repository at this point in the history
* Support an async function to provide vite config

* amend all instances of config.kit.vite

* run pnpm format

* changeset

Co-authored-by: Richard O'flynn <richard.oflynn@brighter-software.co.uk>
Co-authored-by: Rich Harris <hello@rich-harris.dev>
  • Loading branch information
3 people committed Feb 1, 2022
1 parent 316248c commit cf5d4aa
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/sour-shirts-camp.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Allow config.kit.vite to be an async function
2 changes: 1 addition & 1 deletion packages/kit/src/core/build/build_client.js
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/build/build_server.js
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/build/build_service_worker.js
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/dev/index.js
Expand Up @@ -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[]]} */
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/preview/index.js
Expand Up @@ -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) {
Expand Down

0 comments on commit cf5d4aa

Please sign in to comment.