web-backset.cn/apps/web/vite.config.ts
2023-03-21 13:50:20 +08:00

48 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tsconfigPaths from "vite-tsconfig-paths";
import { visualizer } from "rollup-plugin-visualizer";
import viteCompression from "vite-plugin-compression";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
tsconfigPaths(),
visualizer({
open: true, //注意这里要设置为true否则无效
gzipSize: true,
brotliSize: true,
}),
viteCompression(),
],
server: {
proxy: {
"/api": {
rewrite: (path) => path.replace(/^\/api/, ""),
target: "http://127.0.0.1:7001/api/v1",
changeOrigin: true,
},
},
},
build: {
rollupOptions: {
output: {
manualChunks: {
// key不重要会被 chunkFileNames [hash].js重命名
"r-vendor": ["react"],
"rd-vendor": ["react-dom"],
"rdd-vendor": ["react-router-dom"],
"dp-vendor": ["dplayer"],
},
// 入口文件名
entryFileNames: "assets/[hash].js",
// 块文件名
chunkFileNames: "assets/[hash].js",
// 资源文件名 css 图片等等
assetFileNames: "assets/[hash].[ext]",
},
},
},
});