-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
72 lines (71 loc) · 1.85 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"
import { resolve } from "path"
import svgr from "vite-plugin-svgr"
import viteCompression from "vite-plugin-compression"
export default defineConfig({
resolve: {
alias: {
// 如果报错__dirname找不到,需要安装node,执行yarn add @types/node --save-dev
"@": resolve(__dirname, "./src"),
"~antd": resolve(__dirname, "./node_modules/antd"),
},
},
plugins: [react(), svgr(), viteCompression()],
server: {
proxy: {
"/api": {
target: `https://app.clear.ml/api/v22.0`,
changeOrigin: true,
rewrite: (path) => path.replace("/api", ""),
},
},
},
css: {
preprocessorOptions: {
scss: {
javascriptEnabled: true,
additionalData: `@import "@/styles/var.scss";`,
},
},
postcss: {
plugins: [
{
postcssPlugin: "internal:charset-removal",
AtRule: {
charset: (rule) => {
if (rule.name === "charset") {
rule.remove()
}
},
},
},
],
},
},
build: {
minify: "esbuild",
rollupOptions: {
output: {
chunkFileNames: "static/js/chunk-[hash].js",
assetFileNames: (e) => {
let dir = ""
if (e.name) {
const ext = e.name.split(".")[1]
if (["eot", "ttf", "woff", "woff2"].indexOf(ext) !== -1) {
dir = "fonts"
}
if (["svg", "png", "jpg", "jpeg"].indexOf(ext) !== -1) {
dir = "images"
}
if (["css", "scss"].indexOf(ext) !== -1) {
dir = "css"
}
}
return "static/" + dir + "/" + "chunk-[hash][extname]"
},
entryFileNames: "static/js/index.[hash].js",
},
},
},
})