-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.ts
96 lines (93 loc) · 2.9 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { resolve } from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { visualizer } from "rollup-plugin-visualizer";
import viteCompression from "vite-plugin-compression";
import { chunkSplitPlugin } from "vite-plugin-chunk-split";
const pathResolve = (path: string): string => resolve(process.cwd(), path);
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
visualizer({ open: false }),
{
...viteCompression(),
apply: "build",
},
// chunkSplitPlugin({
// strategy: "single-vendor",
// customChunk: (args) => {
// // files into pages directory is export in single files
// let { file, id, moduleId, root } = args;
// if (file.startsWith("src/pages/")) {
// file = file.substring(4);
// file = file.replace(/\.[^.$]+$/, "");
// return file;
// }
// return null;
// },
// // customSplitting: {
// // // `react` and `react-dom` will be bundled together in the `react-vendor` chunk (with their dependencies, such as object-assign)
// // // "react-vendor": ["react", "react-dom"],
// // // Any file that includes `utils` in src dir will be bundled in the `utils` chunk
// // components: [/src\/components/],
// // },
// }),
],
resolve: {
alias: {
"@": pathResolve("src"),
"#": pathResolve("types"),
},
},
server: {
host: "0.0.0.0",
port: 3001,
proxy: {
"/app-api": {
// target: "https://goerli.app.zklink.io",
target: "https://app-api.zklink.io",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/app-api/, ""),
},
"/twitter": {
target: "https://api.twitter.com",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/twitter/, ""),
},
},
},
build: {
target: ["esnext"],
chunkSizeWarningLimit: 1600,
rollupOptions: {
output: {
chunkFileNames: "static/js/[name]-[hash].js",
entryFileNames: "static/js/[name]-[hash].js",
assetFileNames: "static/[ext]/[name]-[hash].[ext]",
manualChunks: {
react: ["react", "react-dom", "react-router-dom"],
nextui: ["@nextui-org/react"],
lodash: ["lodash"],
rainbowkit: ["@rainbow-me/rainbowkit"],
},
},
},
// rollupOptions: {
// output: {
// chunkFileNames: "static/js/[name]-[hash].js",
// entryFileNames: "static/js/[name]-[hash].js",
// assetFileNames: "static/[ext]/[name]-[hash].[ext]",
// // manualChunks(id) {
// // if (id.includes("node_modules")) {
// // return id
// // .toString()
// // .split("node_modules/")[1]
// // .split("/")[0]
// // .toString();
// // }
// // },
// },
// },
},
});