-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
82 lines (79 loc) · 2.04 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
import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
import vitePluginImp from 'vite-plugin-imp'
import path from 'path'
import fs from 'fs'
import lessToJS from 'less-vars-to-js'
const themeVariables = lessToJS(
fs.readFileSync(path.resolve(__dirname, './src/assets/css/variables.less'), 'utf8')
)
// const { getThemeVariables } = require('antd/dist/theme');
console.log('process:::env', process.argv);
// const env = process.argv[process.argv.length - 1];
// https://vitejs.dev/config/
export default defineConfig({
base: './',
plugins: [
reactRefresh(),
vitePluginImp({
optimize: true,
libList: [
{
libName: "antd",
libDirectory: 'es',
style: name => `antd/es/${name}/style`
// style: (name) => `antd/lib/${name}/style/index.less`,
},
],
})
],
resolve: {
// alias: {
// "@": path.resolve(__dirname, 'src'),
// },
alias: [
{find: '@', replacement: path.resolve(__dirname, 'src')},
// {find: /^~/, replacement: '' }
// if set @, need to tsconifg.json below:
// "baseUrl": "./",
// "paths": {
// "@/*":["src/*"]
// }
]
},
css: {
preprocessorOptions: {
less: {
// 支持内联 JavaScript
javascriptEnabled: true,
// 重写 less 变量,定制样式
modifyVars: themeVariables
// getThemeVariables({
// dark: true, // 开启暗黑模式
// compact: true, // 开启紧凑模式
// })
},
}
},
build: {
outDir:'docs',
rollupOptions: {
input: {
index: path.resolve(__dirname, 'index.html'),
info: path.resolve(__dirname, 'info.html')
}
},
cssCodeSplit:true
},
server: {
proxy: {
'/users/': {
target: 'http://localhost:9999',
changeOrigin: true,
headers: {
"uic-token":'0Ud3AIQdpo0F3dhN'
}
}
}
}
})