forked from QiuChenlyOpenSource/MusicDownload
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vite.config.ts
92 lines (89 loc) · 2.32 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
/*
* # Copyright (c) 2023. HackerZer0, Inc. All Rights Reserved
* # @作者 : HackerZer0(HackerZer0)
* # @邮件 : [email protected]
* # @文件 : 项目 [qqmusic] - vite.config.ts
* # @修改时间 : 2023-03-15 03:50:51
* # @上次修改 : 2023/3/15 上午3:50
*/
import { BuildOptions, defineConfig } from "vite";
import path from "path";
import vue from "@vitejs/plugin-vue";
import Icons from "unplugin-icons/vite";
import IconsResolver from "unplugin-icons/resolver";
import Inspect from "vite-plugin-inspect";
import Components from "unplugin-vue-components/vite";
import viteCompression from "vite-plugin-compression";
let pathSrc = path.resolve(__dirname, "src");
// https://vitejs.dev/config/
export default defineConfig({
build: {
outDir: "../flaskSystem/static",
minify: "terser",
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
},
},
rollupOptions: {
output: {
//静态资源分类打包
chunkFileNames: "static/js/[name]-[hash].js",
entryFileNames: "static/js/[name]-[hash].js",
assetFileNames: "static/[ext]/[name]-[hash].[ext]",
manualChunks(id) {
//静态资源分拆打包
if (id.includes("node_modules")) {
return id
.toString()
.split("node_modules/")[1]
.split("/")[0]
.toString();
}
},
},
},
} as BuildOptions,
resolve: {
alias: {
"@": pathSrc,
},
},
plugins: [
vue(),
Components({
resolvers: [IconsResolver()],
}),
Icons({
compiler: "vue3",
autoInstall: true,
}),
Inspect(),
// viteCompression({
// verbose: true,
// disable: false,
// threshold: 10240,
// algorithm: 'gzip',
// ext: '.gz',
// }),
],
css: {
preprocessorOptions: {
scss: {
additionalData: "@import '@/global/MainStyle.scss';",
},
},
},
// server: { //主要是加上这段代码
// // host: '127.0.0.1',
// // port: 3000,
// proxy: {
// '/api': {
// target: 'http://192.168.31.103:8899', //实际请求地址
// changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, '')
// },
// }
// }
});