-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
97 lines (93 loc) · 3.25 KB
/
Copy pathvite.config.ts
File metadata and controls
97 lines (93 loc) · 3.25 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
import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import { nodePolyfills } from "vite-plugin-node-polyfills";
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
return {
base: env.VITE_CDN_URL ? env.VITE_CDN_URL : "/",
build: {
rollupOptions: {
output: {
entryFileNames: 'js/[name]-[hash].js',
chunkFileNames: 'js/[name]-[hash].js',
assetFileNames(assetInfo) {
//文件名称
if (assetInfo.name.endsWith('.css')) {
return 'css/[name]-[hash].css'
}
const fontExts = ['.woff', '.woff2', '.ttf', '.eot']
if (fontExts.some(ext => assetInfo.name.endsWith(ext))) {
return 'fonts/[name]-[hash].[ext]'
}
//图片名称
//定义图片后缀
const imgExts = ['.png', '.jpg', '.jpeg', '.webp', '.gif', '.svg', '.ico']
if (imgExts.some(ext => assetInfo.name.endsWith(ext))) {
return 'images/[name]-[hash].[ext]'
}
//剩余资源文件
return 'assets/[name].[ext]'
},
manualChunks: {
'vue-vendor': ['vue', 'vue-router', 'pinia', 'vue-i18n'],
'library': ['axios', 'dayjs', 'lodash', 'bignumber.js', 'vuetify'],
'echarts': ['echarts'],
'md-editor': ['md-editor-v3'],
'view': ['v-viewer', 'viewerjs', '@yeger/vue-masonry-wall', 'mermaid', 'katex'],
'web3': ['ethers', '@web3-onboard/core', '@web3-onboard/injected-wallets', '@web3-onboard/metamask', '@web3-onboard/walletconnect'],
}
},
}
},
plugins: [
vue(),
nodePolyfills({
// To exclude specific polyfills, add them to this list.
exclude: [
"fs", // Excludes the polyfill for `fs` and `node:fs`.
],
// Whether to polyfill specific globals.
globals: {
Buffer: true, // can also be 'build', 'dev', or false
global: true,
process: true,
},
// Whether to polyfill `node:` protocol imports.
protocolImports: true,
}),
],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
server: {
host: "0.0.0.0",
port: 8080,
proxy: {
"/api": {
target: "https://test-api.protodao.io",
changeOrigin: true,
configure: (proxy, options) => {
proxy.on('proxyReq', function (proxyReq, req, res) {
proxyReq.removeHeader('referer') //移除请求头---最主要是设置这个
proxyReq.removeHeader('origin') //移除请求头---最主要是设置这个
});
},
},
"/dex-api": {
target: "https://test-api.protodao.io",
changeOrigin: true,
configure: (proxy, options) => {
proxy.on('proxyReq', function (proxyReq, req, res) {
proxyReq.removeHeader('referer') //移除请求头---最主要是设置这个
proxyReq.removeHeader('origin') //移除请求头---最主要是设置这个
});
},
},
},
},
}
});