-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
55 lines (52 loc) · 1.54 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
50
51
52
53
54
55
import { defineConfig } from 'vite'
import devConfig from './vite.dev.config'
import prodConfig from './vite.prod.config'
import react from '@vitejs/plugin-react-swc'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
const isProduction = (command: string): command is 'build' =>
command === 'build'
export default defineConfig(({ command }) => {
const isProd = isProduction(command)
const extraConfig = isProd ? prodConfig : devConfig
return {
plugins: [
react(),
AutoImport({
imports: [
'react',
{
react: [
'lazy',
'memo',
'createElement',
'cloneElement',
'isValidElement',
'createContext',
],
},
{
'lodash-es': ['isFunction', 'difference', 'isEqual'],
},
],
dts: `./typings/auto-imports.d.ts`,
eslintrc: {
enabled: true, // Default `false`
filepath: `./.eslintrc-auto-import.json`, // Default `./.eslintrc-auto-import.json`
},
resolvers: [() => null],
}),
],
resolve: {
alias: {
'@src': path.resolve(__dirname, 'src'),
'@hooks': path.resolve(__dirname, 'src/hooks'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@components': path.resolve(__dirname, 'src/components'),
'@constants': path.resolve(__dirname, 'src/constants'),
'@assets': path.resolve(__dirname, 'src/assets'),
},
},
...extraConfig,
}
})