web-backset.cn/apps/web/vite.config.ts

50 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2023-02-27 11:23:36 +08:00
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
2023-03-21 10:39:35 +08:00
import { visualizer } from "rollup-plugin-visualizer";
import viteCompression from "vite-plugin-compression";
2023-02-27 11:23:36 +08:00
// https://vitejs.dev/config/
export default defineConfig({
2023-03-21 10:39:35 +08:00
plugins: [
react(),
tsconfigPaths(),
visualizer({
open: true, //注意这里要设置为true否则无效
gzipSize: true,
brotliSize: true,
}),
viteCompression(),
],
2023-03-12 22:30:09 +08:00
server: {
proxy: {
"/api": {
rewrite: (path) => path.replace(/^\/api/, ""),
target: "http://127.0.0.1:7001/api/v1",
changeOrigin: true,
},
},
},
2023-03-21 10:39:35 +08:00
build: {
2023-03-21 11:22:25 +08:00
rollupOptions: {
output: {
2023-03-21 13:50:20 +08:00
manualChunks: {
// key不重要会被 chunkFileNames [hash].js重命名
"r-vendor": ["react"],
"rd-vendor": ["react-dom"],
"rdd-vendor": ["react-router-dom"],
"dp-vendor": ["dplayer"],
2023-03-21 15:01:44 +08:00
"cry-vendor": ["crypto-js"],
2023-03-21 15:05:14 +08:00
"md-vendor": ["react-markdown"],
2023-03-21 13:50:20 +08:00
},
2023-03-21 11:22:25 +08:00
// 入口文件名
entryFileNames: "assets/[hash].js",
// 块文件名
chunkFileNames: "assets/[hash].js",
// 资源文件名 css 图片等等
assetFileNames: "assets/[hash].[ext]",
},
},
2023-03-21 10:39:35 +08:00
},
2023-02-27 11:23:36 +08:00
});