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

[fix] load errorTemplate from correct location #8096

Merged
merged 1 commit into from
Dec 12, 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/four-ligers-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

[fix] load errorTemplate from correct location
15 changes: 8 additions & 7 deletions packages/kit/src/core/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ export function load_template(cwd, config) {
* @param {import('types').ValidatedConfig} config
*/
export function load_error_page(config) {
const { errorTemplate } = config.kit.files;
let { errorTemplate } = config.kit.files;

// Don't do this inside resolving the config, because that would mean
// adding/removing error.html isn't detected and would require a restart.
if (!fs.existsSync(config.kit.files.errorTemplate)) {
errorTemplate = url.fileURLToPath(new URL('./default-error.html', import.meta.url));
}

return fs.readFileSync(errorTemplate, 'utf-8');
}

Expand Down Expand Up @@ -86,12 +93,6 @@ function process_config(config, { cwd = process.cwd() } = {}) {
}
}

if (!fs.existsSync(validated.kit.files.errorTemplate)) {
validated.kit.files.errorTemplate = url.fileURLToPath(
new URL('./default-error.html', import.meta.url)
);
}

return validated;
}

Expand Down