-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
61 lines (56 loc) · 1.63 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
import path from "node:path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import vitePluginImportus from "vite-plugin-importus";
const wipProjectRoot = process.cwd();
const isPreview = process.env.NODE_ENV_PREVIEW;
/**
* 在script脚本中添加的属性
*/
const BASE_URL = process.env.APP_BASE_URL || "";
console.log("[APP_BASE_URL]", process.env.APP_BASE_URL);
// https://vitejs.dev/config/
export default defineConfig({
base: BASE_URL || isPreview ? `/${BASE_URL}/` : "",
plugins: [
react(),
vitePluginImportus([
{
libraryName: "antd",
libraryDirectory: "es",
style: "css",
},
]),
],
cacheDir: "./.vite.cache",
resolve: {
alias: [
{ find: /^~/, replacement: "" },
{ find: "@Common", replacement: path.resolve(wipProjectRoot, "src/common") },
{ find: "@Pages", replacement: path.resolve(wipProjectRoot, "src/pages") },
{ find: "@Components", replacement: path.resolve(wipProjectRoot, "src/components") },
],
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
define: {
__APP_BASE_URL: JSON.stringify(BASE_URL),
},
build: {
emptyOutDir: true,
rollupOptions: {
output: {
manualChunks: {
react: ["react", "react-dom/client"],
"echarts-gl": ["echarts-gl"],
echarts: ["echarts"],
},
},
},
},
});