-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.ts
More file actions
111 lines (104 loc) · 3.17 KB
/
vite.config.ts
File metadata and controls
111 lines (104 loc) · 3.17 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import react from "@vitejs/plugin-react";
import { defineConfig, loadEnv } from "vite";
import { createHtmlPlugin } from "vite-plugin-html";
import viteTsconfigPaths from "vite-tsconfig-paths";
import pkg from "./package.json";
import visualizer from "rollup-plugin-visualizer";
const path = require("node:path");
const version = pkg.version;
export default ({ mode }: { mode: string }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
return defineConfig({
build: {
// Relative to the root
outDir: "../build",
assetsDir: "",
rollupOptions: {
onwarn: (warning, warn) => {
if (warning.code === "MODULE_LEVEL_DIRECTIVE") {
return;
}
warn(warning);
},
// output: {
// // Efficient chunk splitting
// manualChunks: {
// "react-vendor": ["react", "react-dom"],
// "router-vendor": ["react-router-dom"],
// "ui-vendor": ["@mui/material", "@mui/icons-material"],
// "utils-vendor": ["date-fns"],
// },
// // Optimized file naming
// chunkFileNames: "js/[name]-[hash].js",
// entryFileNames: "js/[name]-[hash].js",
// assetFileNames: (assetInfo) => {
// const info = assetInfo.name.split(".");
// const ext = info[info.length - 1];
// if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(ext)) {
// return `images/[name]-[hash].[ext]`;
// }
// return `assets/[name]-[hash].[ext]`;
// },
// },
// Advanced tree shaking
// treeshake: {
// moduleSideEffects: false,
// propertyReadSideEffects: false,
// },
},
// cssCodeSplit: true,
},
// optimizeDeps: {
// include: ["react", "react-dom", "react-router-dom"],
// exclude: ["@mui/icons-material"],
// },
server: {
// hmr: true,
port: 3000,
proxy: {
"/proxy": {
target: "https://dev.carp.dk",
// target: "http://localhost:8080",
changeOrigin: true,
secure: false,
rewrite: (p) => p.replace(/^\/proxy/, ""),
headers: {
"ngrok-skip-browser-warning": "69420",
},
},
},
},
resolve: {
alias: {
"@Assets": path.resolve(__dirname, "./src/assets"),
"@Components": path.resolve(__dirname, "./src/components"),
"@Modules": path.resolve(__dirname, "./src/components/modules"),
"@Utils": path.resolve(__dirname, "./src/utils"),
},
},
plugins: [
react({
include: "**/*.{jsx,tsx}",
}),
createHtmlPlugin({
inject: {
data: {
title:
process.env.NODE_ENV === "production"
? "Copenhagen Research Platform"
: `🛠️ Copenhagen Research Platform`,
version: version
},
},
}),
viteTsconfigPaths(),
visualizer({
filename: "dist/stats.html",
open: false,
gzipSize: true,
brotliSize: true,
}),
],
base: process.env.VITE_BASE_NAME,
});
};