-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
81 lines (78 loc) · 1.82 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
import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
// import usePluginImport from 'vite-plugin-importer'
import vitePluginImp from 'vite-plugin-imp'
import path from 'path'
import fs from 'fs'
import lessToJS from 'less-vars-to-js'
var themeVariables = lessToJS(
fs.readFileSync(path.resolve(__dirname, 'src/styles/variables.less'), 'utf8')
)
// 需要忽略的分片文件
var ignoreFile = []
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
// usePluginImport({
// libraryName: "antd",
// libraryDirectory: "es",
// style: "css"
// }),
vitePluginImp({
libList: [
{
libName: "antd",
style: (name) => `antd/es/${name}/style`
}
]
}),
reactRefresh()
],
server: {
port: 3000,
// https: true,
host: '0.0.0.0'
},
build: {
outDir: 'build',
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes('node_modules')) {
var fileName = id.toString().split('node_modules/')[1].split('/')[0].toString()
if (ignoreFile.indexOf(fileName) === -1) {
return fileName
}
}
}
}
}
// 去掉console
// terserOptions: {
// compress: {
// drop_console: true,
// pure_funcs: ['console.log']
// }
// }
},
resolve: {
alias: {
// 键必须以斜线开始和结束
'@': path.resolve(__dirname, './src')
}
},
// 修改antd主题色
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
modifyVars: themeVariables
// modifyVars: {
// "primary-color": "#1DA57A",
// "link-color": "#1DA57A",
// "border-radius-base": "2px"
// }
}
}
}
})