web-backset.cn/apps/web/vite.config.ts
2023-03-21 15:05:14 +08:00

50 lines
1.3 KiB
TypeScript
Raw Permalink 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"],
"cry-vendor": ["crypto-js"],
"md-vendor": ["react-markdown"],
},
// 入口文件名
entryFileNames: "assets/[hash].js",
// 块文件名
chunkFileNames: "assets/[hash].js",
// 资源文件名 css 图片等等
assetFileNames: "assets/[hash].[ext]",
},
},
},
});