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

Improve error message when a Svelte config is not found #3219

Merged
merged 14 commits into from
Jan 7, 2022
5 changes: 5 additions & 0 deletions .changeset/neat-points-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Improve error message when a Svelte config is not found
11 changes: 7 additions & 4 deletions packages/kit/src/core/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ export function load_template(cwd, config) {
}

export async function load_config({ cwd = process.cwd() } = {}) {
const config_file_esm = path.join(cwd, 'svelte.config.js');
const config_file = fs.existsSync(config_file_esm)
? config_file_esm
: path.join(cwd, 'svelte.config.cjs');
let config_file = path.join(cwd, 'svelte.config.js');
const config_file_cjs = path.join(cwd, 'svelte.config.cjs');

if (!fs.existsSync(config_file) && fs.existsSync(config_file_cjs)) {
config_file = config_file_cjs;
}

const config = await import(url.pathToFileURL(config_file).href);

const validated = validate_config(config.default);
Expand Down