-
Notifications
You must be signed in to change notification settings - Fork 1
/
svelte.config.js
63 lines (58 loc) · 1.76 KB
/
svelte.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import adapter from '@sveltejs/adapter-vercel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { markdoc } from 'svelte-markdoc-preprocess';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
/**
* @param {string} path Relative path to a file.
* @returns {string} Absolute path to that file.
*/
function absolute(path) {
return join(dirname(fileURLToPath(import.meta.url)), path);
}
/** @type {import('@sveltejs/kit').Config} */
export default {
preprocess: [
vitePreprocess(),
markdoc({
generateSchema: true,
// layouts: {
// default: absolute('./src/lib/markdoc/layouts/default.svelte'),
// docs: absolute('./src/lib/markdoc/layouts/docs.svelte')
// }
nodes: absolute('./src/lib/markdoc/nodes.svelte'),
tags: absolute('./src/lib/markdoc/tags.svelte')
})
],
extensions: ['.markdoc', '.svelte'],
kit: {
adapter: adapter({
images: {
// Restrict image generation to specific widths (Open Props breakpoints).
sizes: [240, 360, 480, 768, 1024, 1440, 1920],
formats: ['image/avif', 'image/webp'],
minimumCacheTTL: 300,
domains: ['www.maier.tech'],
remotePatterns: [
{
protocol: 'https',
// Must match preview URLs, e.g., website-git-835-eliminate-postcss-maierlabs.vercel.app.
hostname: '^website-.*-maierlabs\\.vercel\\.app$'
}
]
}
}),
prerender: {
handleHttpError: ({ path, message }) => {
// Seems like SvelteKit crawler checks image URLs during prerendering.
// But the Vercel image optimization API is not availalbe during a build.
// Ignore image URLs starting with `/_vercel/image`.
if (path == '/_vercel/image') {
return;
}
// Throw an error in all other cases.
throw new Error(message);
}
}
}
};