-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
157 lines (153 loc) · 5.1 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import react from "@vitejs/plugin-react";
import dotenv from "dotenv";
import path from "path";
import { defineConfig } from "vite";
import { ViteEjsPlugin } from "vite-plugin-ejs";
import mkcert from "vite-plugin-mkcert";
import { viteStaticCopy } from "vite-plugin-static-copy";
import svgr from "vite-plugin-svgr";
import { reactVirtualized } from "./fixReactVirtualized";
dotenv.config();
export default defineConfig({
preview: {
port: 8000,
},
build: {
sourcemap: true,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules") && !id.includes("node_modules/@sentry")) {
return id.toString().split("node_modules/")[1].split("/")[0].toString();
}
},
},
},
minify: "terser",
terserOptions: {
compress: {
dead_code: true,
if_return: true,
unused: true,
reduce_vars: true,
reduce_funcs: true,
passes: 2,
},
},
},
define: {
"import.meta.env.VITE_NODE_ENV": JSON.stringify(process.env.VITE_NODE_ENV),
"import.meta.env.VITE_DESCOPE_PROJECT_ID": JSON.stringify(process.env.VITE_DESCOPE_PROJECT_ID),
"import.meta.env.GOOGLE_ANALYTICS_ID": JSON.stringify(process.env.GOOGLE_ANALYTICS_ID),
"import.meta.env.VITE_HOST_URL": JSON.stringify(process.env.VITE_HOST_URL),
"import.meta.env.DISPLAY_DISCORD_INTEGRATION": process.env.DISPLAY_DISCORD_INTEGRATION,
"import.meta.env.DISPLAY_SLACK_SOCKET_INTEGRATION": process.env.DISPLAY_SLACK_SOCKET_INTEGRATION,
"import.meta.env.SENTRY_DSN": JSON.stringify(process.env.SENTRY_DSN),
"import.meta.env.TESTS_JWT_AUTH_TOKEN": JSON.stringify(process.env.TESTS_JWT_AUTH_TOKEN),
"import.meta.env.VITE_GTM_ID": JSON.stringify(process.env.VITE_GTM_ID),
"import.meta.env.VITE_LUCKY_ORANGE_ID": JSON.stringify(process.env.VITE_LUCKY_ORANGE_ID),
"import.meta.env.VITE_HUBSPOT_PORTAL_ID": JSON.stringify(process.env.VITE_HUBSPOT_PORTAL_ID),
"import.meta.env.VITE_HUBSPOT_FORM_ID": JSON.stringify(process.env.VITE_HUBSPOT_FORM_ID),
"import.meta.env.VITE_HEIGHT_HIDE_DEFAULT_OAUTH": process.env.VITE_HEIGHT_HIDE_DEFAULT_OAUTH,
"import.meta.env.VITE_LINEAR_HIDE_DEFAULT_OAUTH": process.env.VITE_LINEAR_HIDE_DEFAULT_OAUTH,
"import.meta.env.VITE_ZOOM_HIDE_DEFAULT_OAUTH": process.env.VITE_ZOOM_HIDE_DEFAULT_OAUTH,
},
optimizeDeps: {
include: ["tailwind-config"],
},
plugins: [
...(process.env.VITE_LOCAL_SSL_CERT === "true" ? [mkcert()] : []),
react(),
ViteEjsPlugin((viteConfig) => ({
env: viteConfig.env,
})),
svgr({
svgrOptions: {
ref: true,
icon: false,
replaceAttrValues: {
"#000": "currentColor",
},
svgoConfig: {
multipass: true,
plugins: [
{
name: "preset-default",
params: {
overrides: {
removeViewBox: false,
cleanupIDs: false,
removeUselessStrokeAndFill: false,
removeUnknownsAndDefaults: false,
convertPathData: {
floatPrecision: 2,
transformPrecision: 4,
},
cleanupNumericValues: {
floatPrecision: 2,
},
collapseGroups: true,
mergePaths: true,
convertTransform: true,
convertShapeToPath: true,
removeEmptyAttrs: true,
removeEmptyContainers: true,
removeUnusedNS: true,
sortAttrs: true,
},
},
},
],
},
},
}),
viteStaticCopy({
targets: [
{
src: "src/assets/templates/**/*",
dest: "assets/templates",
},
{
src: "src/assets/new_project_program/**/*",
dest: "assets/new_project_program",
},
{
src: "src/assets/image/pages/**/*",
dest: "assets/image/pages",
},
],
}),
reactVirtualized(),
],
resolve: {
alias: {
"@src": path.resolve(__dirname, "./src"),
"@ak-proto-ts": path.resolve(__dirname, "./src/autokitteh/proto/gen/ts/autokitteh"),
"@api": path.resolve(__dirname, "./src/api"),
"@assets": path.resolve(__dirname, "./src/assets"),
"@components": path.resolve(__dirname, "./src/components"),
"@contexts": path.resolve(__dirname, "./src/contexts"),
"@constants": path.resolve(__dirname, "./src/constants"),
"@enums": path.resolve(__dirname, "./src/enums"),
"@hooks": path.resolve(__dirname, "./src/hooks"),
"@i18n": path.resolve(__dirname, "./src/i18n"),
"@interfaces": path.resolve(__dirname, "./src/interfaces"),
"@locales": path.resolve(__dirname, "./src/locales"),
"@models": path.resolve(__dirname, "./src/models"),
"@pages": path.resolve(__dirname, "./pages"),
"@routing": path.resolve(__dirname, "./src/routing"),
"@services": path.resolve(__dirname, "./src/services"),
"@store": path.resolve(__dirname, "./src/store"),
"@type": path.resolve(__dirname, "./src/types"),
"@utilities": path.resolve(__dirname, "./src/utilities"),
"@utils": path.resolve(__dirname, "./src/utils"),
"@validations": path.resolve(__dirname, "./src/validations"),
"tailwind-config": path.resolve(__dirname, "./tailwind.config.cjs"),
},
},
server: {
host: process.env.VITE_APP_DOMAIN ? JSON.stringify(process.env.VITE_APP_DOMAIN) : true,
port: process.env.VITE_LOCAL_PORT ? Number(process.env.VITE_LOCAL_PORT) : 8000,
strictPort: true,
},
});