-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
105 lines (103 loc) · 3.2 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
import { resolve } from 'path';
import { defineConfig, splitVendorChunkPlugin } from 'vite';
import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import { visualizer } from 'rollup-plugin-visualizer';
import viteCompression from 'vite-plugin-compression';
import Icons from 'unplugin-icons/vite';
import IconsResolver from 'unplugin-icons/resolver';
import path from 'path';
// https://vitejs.dev/config/
/** @type {import('vite').UserConfig} */
const pathSrc = path.resolve(__dirname, 'src');
export default defineConfig({
base: 'https://static.vio.vin/share/',
server: {
proxy: {
'/api': {
target: 'https://share.vio.vin/api',
// target: 'http://127.0.0.1:8888/api',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
port: 3000,
},
resolve: {
alias: {
'@': pathSrc,
},
},
plugins: [
vue(),
visualizer(),
AutoImport({
imports: ['vue'],
resolvers: [ElementPlusResolver(), IconsResolver({ prefix: 'Icon' })],
dts: path.resolve(pathSrc, 'auto-imports.d.ts'),
}),
Components({
resolvers: [
ElementPlusResolver(),
IconsResolver({
enabledCollections: [
'ep',
'vscode-icons',
'logos',
'material-symbols',
'mdi',
'bx',
'bxs',
'ant-design',
],
}),
],
dts: path.resolve(pathSrc, 'components.d.ts'),
}),
splitVendorChunkPlugin(),
viteCompression({
verbose: true,
disable: false,
threshold: 1024,
algorithm: 'gzip',
ext: '.gz',
}),
Icons({
autoInstall: true,
}),
],
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
},
output: {
manualChunks: (id) => {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
},
entryFileNames: 'js/[name].[hash].js',
chunkFileNames: 'js/[name].[hash].js',
assetFileNames: 'assets/[ext]/[name].[hash].[ext]',
// @ts-ignore
assetUrl: (assetInfo) => {
const { name, ext } = assetInfo;
return `https://static.vio.vin/share/${ext}/${name}.${ext}`;
},
},
},
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
},
define: {
'process.env': {},
},
});