-
Notifications
You must be signed in to change notification settings - Fork 4
/
vite.config.ts
49 lines (42 loc) · 1.34 KB
/
vite.config.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
import type { UserConfigExport } from 'vite'
import path from 'node:path'
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import { viteMockServe } from '@lincy/vite-plugin-mock'
import UnoCSS from 'unocss/vite'
import { defineConfig, loadEnv } from 'vite'
import Build from './vite.config.build'
import Components from './vite.config.components'
import Css from './vite.config.css'
import Macros from './vite.config.macros'
import PWA from './vite.config.pwa'
// https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => {
const __dirname = path.dirname(fileURLToPath(import.meta.url))
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
const localMock = true
const config: UserConfigExport = {
base: '/',
server: Build.server,
build: Build.build,
css: Css,
plugins: [
...Macros(),
...Components(),
viteMockServe({
mockPath: 'mock',
enable: command === 'serve' && localMock,
logger: true,
}),
UnoCSS({}),
...PWA(),
],
resolve: {
alias: {
'~': path.join(__dirname, './src'),
'@': path.join(__dirname, './src'),
},
},
}
return config
})