-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
53 lines (51 loc) · 1.4 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import vitePluginCompression from "vite-plugin-compression";
// @ts-ignore
import path from "node:path";
const baseUrl = "json-to-ts-typing";
// https://vitejs.dev/config/
export default defineConfig((config) => {
return {
resolve: {
alias: {
// @ts-ignore
"@": path.resolve(__dirname, "src"),
},
},
plugins: [
react(),
vitePluginCompression({
threshold: 1024 * 10, // 对大于 10kb 的文件进行压缩
// deleteOriginFile: true,
}),
],
server: {
open: true,
},
base: config.mode === "development" ? "/" : `/${baseUrl}/`,
build: {
minify: false,
outDir: baseUrl,
// 关闭文件计算
reportCompressedSize: false,
sourcemap: false,
rollupOptions: {
output: {
chunkFileNames: "js/[name]-[hash].js", // 引入文件名的名称
entryFileNames: "js/[name]-[hash].js", // 包的入口文件名称
assetFileNames: "[ext]/[name]-[hash].[ext]", // 资源文件像 字体,图片等
manualChunks(id) {
if (id.includes("node_modules")) {
return id
.toString()
.split("node_modules/")[1]
.split("/")[0]
.toString();
}
},
},
},
},
};
});