-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathvite.config.ts
80 lines (79 loc) · 2.26 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
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 { defineConfig } from 'vite'
import PurgeIcons from 'vite-plugin-purge-icons'
import pkg from './package.json'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import vueJSX from '@vitejs/plugin-vue-jsx'
import vueI18n from './vite/plugins/i18n'
import antdTheme from './vite/plugins/antdTheme'
import modifyVars from './src/styles/theme/vars'
const pathResolve = (dir: string) => resolve(__dirname, '.', dir)
const { dependencies, devDependencies, name, version } = pkg
import moment from 'moment'
const __APP_INFO__ = {
pkg: { dependencies, devDependencies, name, version },
lastBuildTime: moment().format('YYYY-MM-DD HH:mm:ss')
}
const viteConfig = defineConfig({
// the key **must start and end with a slash**
resolve: {
alias: [
{
find: /\/@\//,
replacement: pathResolve('src') + '/'
},
{
find: /\/vt\//,
replacement: pathResolve('vite') + '/'
},
{
find: /\/imgs\//,
replacement: pathResolve('src') + '/assets/images/'
},
{
find: /\/#\//,
replacement: pathResolve('types') + '/'
}
]
},
base: '/',
define: {
__APP_INFO__: JSON.stringify(__APP_INFO__)
},
envDir: pathResolve('./env'),
css: {
preprocessorOptions: {
less: {
modifyVars: {
// reference: Avoid repeated references
// hack: `true; @import (reference) "${resolve('src/design/config.less')}";`,
...modifyVars
},
javascriptEnabled: true
}
}
},
server: {
host: true,
port: 3399,
open: false
},
optimizeDeps: {
include: ['@ant-design/icons-vue', 'ant-design-vue/es/locale/zh_CN', 'ant-design-vue/es/locale/en_US']
},
plugins: [
vue(),
vueJSX(),
PurgeIcons(),
vueI18n(),
antdTheme({
colors: {
blue: '#442288',
red: '#333'
}
// dark: true
// backgroundColor: 'red'
})
]
})
export default viteConfig