-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvelte.config.js
77 lines (73 loc) · 1.89 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import adapter from '@sveltejs/adapter-vercel';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { mdsvex, escapeSvelte } from 'mdsvex';
import { createHighlighter } from 'shiki';
/** @type {import('shiki').Highlighter | null} */
const highlighter = await createHighlighter({
themes: ['min-light', 'min-dark'],
langs: [
'bash',
'html',
'javascript',
'json',
'markdown',
'svelte',
'text',
'typescript',
'yaml',
'xml'
]
});
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
extensions: ['.svx'],
layout: {
_: './src/lib/mdsvex/layouts/default.svelte'
},
highlight: {
highlighter: async (code, lang = 'text') => {
const html = escapeSvelte(
highlighter.codeToHtml(code, {
lang,
themes: { light: 'min-light', dark: 'min-dark' }
})
);
return `{@html \`${html}\` }`;
}
}
};
/** @type {import('@sveltejs/kit').Config} */
export default {
extensions: ['.svelte', '.svx'],
preprocess: [vitePreprocess(), mdsvex(mdsvexOptions)],
kit: {
adapter: adapter({
images: {
// Restrict image generation to specific widths (Tailwind CSS breakpoints).
sizes: [640, 768, 1024, 1280, 1536],
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 the 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);
}
}
}
};