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

Support an async function to provide vite config #3565

Merged
merged 4 commits into from
Feb 1, 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/sour-shirts-camp.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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