Skip to content

Commit

Permalink
make svelte config optional
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed May 29, 2022
1 parent cc44f11 commit 2d335b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ prog

/** @type {import('vite').UserConfig} */
const config = {
plugins: [...(vite_config.plugins || []), plugins(svelte_config)]
plugins: [...(vite_config.plugins || []), await plugins(svelte_config)]
};
config.server = {};

Expand Down
9 changes: 5 additions & 4 deletions packages/kit/src/vite/plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { svelte as svelte_plugin } from '@sveltejs/vite-plugin-svelte';
import path from 'path';
import { searchForWorkspaceRoot } from 'vite';
import { print_config_conflicts } from '../core/config/index.js';
import { load_config, print_config_conflicts } from '../core/config/index.js';
import { get_aliases, get_runtime_path } from '../core/utils.js';
import { deep_merge } from '../utils/object.js';
import { configure_server } from './dev.js';
Expand Down Expand Up @@ -99,9 +99,10 @@ const svelte = function (svelte_config) {
};

/**
* @param {import('types').ValidatedConfig} svelte_config
* @return {import('vite').Plugin[]}
* @param {import('types').ValidatedConfig} [svelte_config]
* @return {Promise<import('vite').Plugin[]>}
*/
export const plugins = function (svelte_config) {
export const plugins = async function (svelte_config) {
svelte_config = svelte_config || (await load_config());
return [...svelte(svelte_config), sveltekit(svelte_config)];
};

0 comments on commit 2d335b7

Please sign in to comment.