-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsvelte.config.js
More file actions
65 lines (55 loc) · 1.72 KB
/
Copy pathsvelte.config.js
File metadata and controls
65 lines (55 loc) · 1.72 KB
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
import { mdsvex } from 'mdsvex';
import adapter from '@sveltejs/adapter-cloudflare';
import { patchCloudflareWorker } from './scripts/patch-cloudflare-worker.mjs';
/** @type {import('mdsvex').MdsvexOptions} */
const mdsvexOptions = {
extensions: ['.svx'],
highlight: {
alias: {
js: 'javascript',
sh: 'bash',
shell: 'bash',
ts: 'typescript',
yml: 'yaml'
}
}
};
const mdsvexPreprocess = mdsvex(mdsvexOptions);
function cloudflareAdapterWithCachePatch(options) {
const cloudflare = adapter(options);
return {
...cloudflare,
async adapt(builder) {
await cloudflare.adapt(builder);
await patchCloudflareWorker();
}
};
}
const normalizeMdsvexModuleScript = {
markup: async (options) => {
const result = await mdsvexPreprocess.markup?.(options);
if (!result?.code) {
return result;
}
return {
...result,
code: result.code.replace(/<script\s+context=(['"])module\1>/g, '<script module>')
};
}
};
/** @type {import('@sveltejs/kit').Config} */
const config = {
compilerOptions: {
// Force runes mode for the project, except for libraries. Can be removed in svelte 6.
runes: ({ filename }) => (filename.split(/[/\\]/).includes('node_modules') ? undefined : true)
},
kit: {
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: cloudflareAdapterWithCachePatch()
},
preprocess: [normalizeMdsvexModuleScript],
extensions: ['.svelte', '.svx']
};
export default config;