-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.js
82 lines (80 loc) · 2.63 KB
/
vite.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
78
79
80
81
82
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
import { mdsvex } from 'mdsvex'
import { readFileSync } from 'fs'
import routify from '@roxi/routify/vite-plugin'
const production = process.env.NODE_ENV === 'production'
export default defineConfig({
clearScreen: false,
plugins: [
routify({
routesDir: {
default: 'src/routes',
exampleWidget:
'src/routes/docs/1.guide/3.advanced/multiple-routers/example.shared-tree/widget',
},
ignoreMetaConflictWarnings: [
'todo',
'movies',
'luke',
'leia',
'darth|split',
'status',
],
render: {
ssg: { enable: !!production },
ssr: { enable: !!production },
},
devHelper: !production,
// devHelper: !production,
extensions: ['.svelte', '.html', '.md', '.svx', '.meta.js'],
plugins: [
'plugins/indexByName',
'plugins/ownSourceMetaPlugin',
{
name: 'exclude-meta.js',
before: 'metaSplit',
build: ({ instance, tools }) => {
// .js files are not routes
instance.nodeIndex.forEach(node => {
if (node.file.base.endsWith('meta.js')) {
node.meta.noRoute = true
node.meta.isDefault = false
}
})
},
},
],
}),
svelte({
emitCss: !production,
compilerOptions: {
dev: !production,
hydratable: !!process.env.ROUTIFY_SSR_ENABLE,
},
extensions: ['.md', '.svelte'],
preprocess: [mdsvex({ extension: 'md' })],
}),
{
name: 'svg',
transform: (code, id) =>
id.endsWith('.svg')
? 'export default ' + JSON.stringify(readFileSync(id, 'utf-8'))
: null,
},
{
name: 'meta-in-md',
transform: (code, id) =>
id.endsWith('.md')
? code.replace(/routify::meta/g, 'routify:meta')
: null,
},
],
server: { port: 1337 },
optimizeDeps: { include: ['prismjs'] },
resolve: {
alias: {
'#cmp': process.cwd() + '/src/components',
},
},
})