-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
47 lines (46 loc) · 1.19 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
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import tailwindcss from "tailwindcss";
import autoprefixer from "autoprefixer";
import path from 'path';
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
server: {
/** 设置 host: true 才可以使用 Network 的形式,以 IP 访问项目 */
host: true, // host: "0.0.0.0"
/** 是否自动打开浏览器 */
open: false,
/** 跨域设置允许 */
cors: true,
/** 端口被占用时,是否直接退出 */
strictPort: false,
// 热模块替换
hmr: true,
proxy: {
"/api": {
target: "http://api.fanyi.baidu.com",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
},
},
},
build: {
/** 单个 chunk 文件的大小超过 2048KB 时发出警告 */
chunkSizeWarningLimit: 2048,
/** 禁用 gzip 压缩大小报告 */
reportCompressedSize: false,
/** 打包后静态资源目录 */
assetsDir: "static",
},
css: {
postcss: {
plugins: [tailwindcss, autoprefixer],
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
});