Skip to content

Commit

Permalink
[fix] load errorTemplate from correct location (#8096)
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Dec 12, 2022
1 parent ab5f1c1 commit ba95b64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/four-ligers-help.md
@@ -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
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

0 comments on commit ba95b64

Please sign in to comment.