This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
/
vite.ts
80 lines (79 loc) · 2.08 KB
/
vite.ts
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
import { resolve } from 'pathe'
import { withoutLeadingSlash } from 'ufo'
import { defineUntypedSchema } from 'untyped'
export default defineUntypedSchema({
/**
* Configuration that will be passed directly to Vite.
*
* See https://vitejs.dev/config for more information.
* Please note that not all vite options are supported in Nuxt.
*
* @type {typeof import('../src/types/config').ViteConfig}
*/
vite: {
root: {
$resolve: async (val, get) => val ?? (await get('srcDir'))
},
mode: {
$resolve: async (val, get) => val ?? (await get('dev') ? 'development' : 'production')
},
logLevel: 'warn',
define: {
$resolve: async (val, get) => ({
'process.dev': await get('dev'),
...val || {}
})
},
resolve: {
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
publicDir: {
$resolve: async (val, get) => val ?? resolve((await get('srcDir')), (await get('dir')).public)
},
vue: {
isProduction: {
$resolve: async (val, get) => val ?? !(await get('dev'))
},
template: {
compilerOptions: {
$resolve: async (val, get) => val ?? (await get('vue')).compilerOptions
}
}
},
optimizeDeps: {
exclude: {
$resolve: async (val, get) => [
...val || [],
...(await get('build.transpile')).filter((i: string) => typeof i === 'string'),
'vue-demi'
]
}
},
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
tsconfigRaw: '{}'
},
clearScreen: false,
build: {
assetsDir: {
$resolve: async (val, get) => val ?? withoutLeadingSlash((await get('app')).buildAssetsDir)
},
emptyOutDir: false
},
server: {
fs: {
allow: {
$resolve: async (val, get) => [
await get('buildDir'),
await get('srcDir'),
await get('rootDir'),
await get('workspaceDir'),
...(await get('modulesDir')),
...val ?? []
]
}
}
}
}
})