-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
svelte.config.js
54 lines (45 loc) · 1.27 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
import sveltePreprocess from "svelte-preprocess"
import adapterVercel from "@sveltejs/adapter-vercel"
import path from "path"
import { readdirSync } from "fs"
/**
* Lists urls of all static routes in `path`.
*
* @param {string} p - The path to search
*
* @returns {string[]}
*/
function listRoutesIn(p) {
const routesPath = path.join("./src/routes/", p)
const dir = readdirSync(routesPath, { withFileTypes: true })
const filenames = dir
.filter(({ isFile, name }) => isFile && !name.startsWith("_"))
.map((dirent) => dirent.name)
if (filenames.length === 0) {
throw new Error(`listRoutesIn: No static routes found in '${p}'`)
}
const routes = filenames.map((filename) => {
const name = path.parse(filename).name
return path.join("/", p, name)
})
return routes
}
/** @type {import('@sveltejs/kit').Config} */
const config = {
// an array of file extensions that should be treated as Svelte components
extensions: [".svelte"],
kit: {
adapter: adapterVercel(),
prerender: {
enabled: true,
default: true,
entries: ["*", ...listRoutesIn("/icon/")]
},
alias: {
$: "src"
}
},
// options passed to svelte.preprocess (https://svelte.dev/docs#svelte_preprocess)
preprocess: sveltePreprocess({ postcss: true, typescript: true })
}
export default config