-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvite.config.ts
More file actions
156 lines (153 loc) · 4.35 KB
/
vite.config.ts
File metadata and controls
156 lines (153 loc) · 4.35 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import { createHtmlPlugin } from 'vite-plugin-html';
import packageJson from './package.json';
import legacy from '@vitejs/plugin-legacy';
import { federation } from '@module-federation/vite';
import { getDevInfo, getProxy, logDevInfo } from './supos.dev';
const devInfo = getDevInfo();
const proxy = getProxy(devInfo.API_PROXY_URL, devInfo.SINGLE_API_PROXY_LIST, devInfo.SINGLE_API_PROXY_URL);
logDevInfo(devInfo);
// 生成格式化的时间
const buildTime = new Date().toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false, // 24小时制
});
// https://vite.dev/config/
export default defineConfig({
base: devInfo.VITE_ASSET_PREFIX || '/',
esbuild: {
drop: ['debugger'],
pure: ['console.log'],
supported: {
'top-level-await': true,
},
},
plugins: [
react(),
legacy({
targets: ['chrome>=89', 'safari>=15', 'firefox>=89', 'edge>=89'],
modernPolyfills: true,
}),
createHtmlPlugin({
inject: {
data: {
VITE_APP_TITLE: process.env.VITE_APP_TITLE || 'supOS',
},
},
}),
federation({
name: 'supos-ce/host',
manifest: true,
// remotes: {
// // 静态引入示例
// 'supos-ce/CodeManagement': {
// type: 'module',
// name: 'supos-ce/CodeManagement',
// entry: 'http://100.100.100.22:33993/plugin/CodeManagement/mf-manifest.json',
// },
// },
exposes: {
'./components': './src/components/index.ts',
'./utils': './src/utils/index.ts',
'./hooks': './src/hooks/index.ts',
'./apis': './src/apis/inter-api/index.ts',
'./button-permission': './src/common-types/button-permission.ts',
'./constans': './src/common-types/constans.ts',
'./i18nStore': './src/stores/i18n-store.ts',
'./baseStore': './src/stores/base/index.ts',
'./tabs-lifecycle-context': './src/contexts/tabs-lifecycle-context.ts',
'./useTabsContext': './src/contexts/tabs-context.ts',
},
shared: {
react: {
singleton: true,
requiredVersion: '^18.3.1',
},
'react-dom': {
singleton: true,
requiredVersion: '^18.3.1',
},
'react-router-dom': {
singleton: true,
requiredVersion: '^6.27.0',
},
antd: {
singleton: true,
requiredVersion: '5.27.1',
},
'@ant-design/icons': {
singleton: true,
requiredVersion: '6.0.0',
},
ahooks: {
singleton: true,
requiredVersion: '^3.8.5',
},
'@carbon/icons-react': {
singleton: true,
requiredVersion: '^11.60.0',
},
lodash: {
singleton: true,
requiredVersion: '^4.17.21',
},
sass: {
singleton: true,
requiredVersion: '^1.80.4',
},
},
}),
],
// css: {
// preprocessorOptions: {
// scss: {
// includePaths: ['node_modules'],
// // javascriptEnabled: true,
// quietDeps: true,
// },
// },
// },
assetsInclude: ['**/*.woff2', '**/*.woff', '**/*.ttf'],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
//导入文件时省略的扩展名
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx'],
},
define: {
'process.env': { ...devInfo },
'import.meta.env.VITE_APP_VERSION': JSON.stringify(packageJson.version),
'import.meta.env.VITE_APP_BUILD_TIMESTAMP': JSON.stringify(buildTime),
},
envPrefix: ['REACT_APP_', 'VITE_', 'OPENAI_'],
server: {
origin: devInfo.VITE_ASSET_PREFIX,
proxy: {
...proxy,
// '/copilotkit': 'http://localhost:4000',
...(devInfo.VITE_ASSET_PREFIX !== '1'
? {
'/plugin/': {
target: devInfo.API_PROXY_URL,
changeOrigin: true,
// agent: new HttpsProxyAgent('http://127.0.0.1:7897'),
},
}
: {
'/mf-manifest.json': devInfo.VITE_ASSET_PREFIX,
}),
},
},
build: {
outDir: 'build', // 设置构建输出目录为 build
target: ['chrome89', 'edge89', 'firefox89', 'safari15'],
},
});