-
Notifications
You must be signed in to change notification settings - Fork 75
/
vite.config.ts
87 lines (83 loc) · 2 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
81
82
83
84
85
86
import type { UserConfigExport, ConfigEnv } from 'vite'
import { loadEnv } from 'vite';
import reactRefresh from '@vitejs/plugin-react-refresh'
import { viteMockServe } from 'vite-plugin-mock'
import { resolve } from 'path';
import svgr from 'vite-plugin-svgr'
import { getAliases } from "vite-aliases";
import styleImport from 'vite-plugin-style-import';
const aliases = getAliases();
function pathResolve(dir: string) {
return resolve(__dirname, '.', dir);
}
// https://vitejs.dev/config/
export default ({ command } : { command: string}) => {
console.log('command:',)
return {
resolve: {
// alias: aliases,
alias: [
{
// /@/xxxx => src/xxx
find: /^~/,
replacement: pathResolve('node_modules') + '/',
},
{
// /@/xxxx => src/xxx
find: /@\//,
replacement: pathResolve('src') + '/',
},
],
},
optimizeDeps: {
include: [
'@ant-design/colors',
'@ant-design/icons',
],
},
// server: {
// proxy: {
// '/api': {
// target: 'http://127.0.0.1:7770',
// changeOrigin: true,
// rewrite: path => path.replace(/^\/api/, '')
// }
// },
// },
plugins: [
reactRefresh(),
svgr(),
viteMockServe({
mockPath: 'mock',
supportTs: true,
watchFiles: true,
localEnabled: command === 'serve',
logger: true,
}),
// styleImport({
// libs: [
// {
// libraryName: 'antd',
// esModule: true,
// resolveStyle: (name) => {
// return `antd/es/${name}/style/index`;
// },
// },
// ],
// }),
],
css: {
modules: {
localsConvention: 'camelCaseOnly',
},
preprocessorOptions: {
less: {
javascriptEnabled: true,
modifyVars: {
'@primary-color': '#1890ff',
},
},
},
},
}
}