-
Notifications
You must be signed in to change notification settings - Fork 78
/
vite.config.ts
138 lines (133 loc) · 4.23 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*
* Copyright 2022 Nightingale Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { defineConfig, loadEnv } from 'vite';
import reactRefresh from '@vitejs/plugin-react-refresh';
import { md } from './plugins/md';
import plusResolve from './plugins/plusResolve';
import prefixPlugin from './plugins/vite-plugin-prefix';
const reactSvgPlugin = require('./plugins/svg');
const chunk2 = [
'@codemirror/autocomplete',
'@codemirror/highlight',
'@codemirror/lint',
'@codemirror/language',
'@codemirror/state',
'@codemirror/view',
'codemirror-promql',
'@codemirror/basic-setup',
];
const chunk3 = ['react-ace'];
const chunk1 = ['react', 'react-router-dom', 'react-dom', 'moment', '@ant-design/icons', 'umi-request', 'lodash', 'react-grid-layout', 'd3', 'ahooks', 'color'];
const antdChunk = ['antd'];
const excelChunk = ['file-saver', 'exceljs'];
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
// 后端接口地址
// 也可以通过环境变量来设置,创建 `.env` 文件,内容为 `PROXY=http://localhost:8080`
let proxyURL = env.PROXY || 'http://localhost:8080';
let fontFamily = '"Microsoft Yahei",Verdana,Helvetica Neue,sans-serif,PingFangSC-Regular,simsun,"sans-serif"';
if (env.VITE_IS_PRO) {
proxyURL = env.PROXY_PRO;
} else if (env.VITE_IS_ENT) {
proxyURL = env.PROXY_ENT;
fontFamily = 'Helvetica Neue,sans-serif,PingFangSC-Regular,microsoft yahei ui,microsoft yahei,simsun,"sans-serif"';
}
const baseName = env.VITE_PREFIX || '';
return {
base: baseName + '/',
plugins: [
md(),
reactRefresh(),
plusResolve(),
reactSvgPlugin({ defaultExport: 'component' }),
//
prefixPlugin(baseName),
],
define: {},
resolve: {
alias: [
{
find: '@assets',
replacement: baseName,
},
{
find: '@',
replacement: '/src',
},
],
},
server: {
proxy: {
'/api': {
target: proxyURL,
changeOrigin: true,
},
},
},
build: {
commonjsOptions: {
ignoreTryCatch: false, // https://github.com/wbkd/react-flow/issues/1840
},
outDir: 'pub',
chunkSizeWarningLimit: 650,
sourcemap: false,
rollupOptions: {
output: {
manualChunks: {
vendor: chunk1,
vendor1: chunk2,
vendor2: chunk3,
antdChunk: antdChunk,
excelChunk,
},
},
},
},
css: {
preprocessorOptions: {
less: {
additionalData: `@import "/src/global.variable.less";`,
javascriptEnabled: true,
modifyVars: {
'primary-color': '#6C53B1',
'primary-background': '#F0ECF9',
'disabled-color': 'rgba(0, 0, 0, 0.5)',
'tabs-ink-bar-color': 'linear-gradient(to right, #9F4CFC, #0019F4 )',
'font-size-base': '12px',
'menu-item-font-size': '14px',
'radio-button-checked-bg': '#EAE6F3',
'form-item-margin-bottom': '18px',
'font-family': fontFamily,
'text-color': '#262626',
'table-row-hover-bg': '#EAE8F2',
'table-header-bg': '#f0f0f0',
'select-selection-item-bg': '#EAE6F3',
'select-selection-item-border-color': '#6C53B1',
'menu-item-color': '#8C8C8C',
'menu-inline-submenu-bg': '#f0f0f0',
'menu-bg': '#f0f0f0',
'checkbox-check-bg': '#fff',
'checkbox-check-color': '#6C53B1',
'checkbox-color': 'fade(@checkbox-check-color, 10)',
'btn-padding-horizontal-base': '12px',
},
},
},
},
};
});