-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuxt.config.ts
More file actions
291 lines (269 loc) · 9.16 KB
/
nuxt.config.ts
File metadata and controls
291 lines (269 loc) · 9.16 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
export default defineNuxtConfig({
devtools: { enabled: process.env.NODE_ENV === 'development' },
modules: ["@nuxtjs/tailwindcss", "nuxt-plotly"],
css: ["@/assets/css/main.css"],
alias: {
components: './components',
utils: './lib/utils'
},
// Dev server configuration
devServer: {
port: process.env.PORT ? parseInt(process.env.PORT) : 3000,
host: 'localhost',
https: false
},
components: [
{
path: '~/components',
pathPrefix: false,
ignore: ['**/ui/**']
}
],
runtimeConfig: {
public: {
siteUrl: process.env.NUXT_PUBLIC_SITE_URL || process.env.SITE_URL,
backendUrl: process.env.NUXT_PUBLIC_BACKEND_URL || process.env.BACKEND_URL || 'http://localhost:3001',
enableGalaxy: process.env.NUXT_PUBLIC_ENABLE_GALAXY === 'true' || false,
enableAuth: process.env.NUXT_PUBLIC_ENABLE_AUTH === 'true' || process.env.NODE_ENV !== 'production' || false
}
},
tailwindcss: {
exposeConfig: false,
},
// PostCSS is handled automatically by @nuxtjs/tailwindcss module
// Removing explicit config to avoid conflicts with import.meta
// postcss: {
// plugins: {
// tailwindcss: {},
// autoprefixer: {},
// },
// },
vite: {
define: {
// Workaround for crypto.hash issue in @vitejs/plugin-vue 5.0.0
'global': 'globalThis',
// Fix for import.meta issue in PostCSS/Tailwind
'import.meta.dev': 'false',
'import.meta.prod': 'true',
'import.meta.client': 'true',
'import.meta.server': 'false',
},
optimizeDeps: {
include: [
"plotly.js-dist-min",
"oh-vue-icons",
"oh-vue-icons/icons",
"highcharts",
"highcharts-vue",
"exceljs",
"jspdf",
"file-saver",
"jszip"
],
// Exclude TanStack Query from optimization to prevent class inheritance issues
exclude: ['@tanstack/vue-query', '@tanstack/query-core'],
esbuildOptions: {
target: 'es2020', // Match build target
keepNames: true // Preserve class names to avoid minification issues
},
// Force re-optimization of oh-vue-icons to include all icon modules
force: process.env.NODE_ENV === 'development' ? ['oh-vue-icons'] : undefined
},
build: (() => {
const isProduction = process.env.NODE_ENV === 'production';
const buildConfig: any = {
target: 'es2020',
// Disable minification completely to prevent class inheritance issues
// TanStack Query and other libraries break with minification
minify: false,
sourcemap: true,
chunkSizeWarningLimit: 1000,
commonjsOptions: {
include: [/node_modules/],
transformMixedEsModules: true
},
rollupOptions: {
output: {
// Preserve class names in output
generatedCode: {
constBindings: true
},
// Preserve function and class names in chunk names
chunkFileNames: '[name]-[hash].js',
entryFileNames: '[name]-[hash].js',
assetFileNames: '[name]-[hash].[ext]',
manualChunks(id: string) {
// Split large dependencies into separate chunks to avoid 43MB bundle
if (id.includes("node_modules")) {
// Core Vue ecosystem - keep together
if (id.includes("vue") || id.includes("vue-router") || id.includes("@vue")) {
return "vue-core";
}
// TanStack Query - keep separate and unminified
// This library has class inheritance that breaks with minification
if (id.includes("@tanstack/vue-query") || id.includes("@tanstack/query")) {
return "vue-query";
}
// Large charting libraries - split separately (these are huge)
if (id.includes("highcharts")) {
return "highcharts";
}
if (id.includes("plotly")) {
return "plotly";
}
// Export libraries - split separately (large, used only in PrivateTable)
if (id.includes("exceljs")) {
return "exceljs";
}
if (id.includes("jspdf")) {
return "jspdf";
}
if (id.includes("jszip")) {
return "jszip";
}
if (id.includes("file-saver")) {
return "file-saver";
}
// UI libraries - group together
if (id.includes("oh-vue-icons")) {
return "oh-vue-icons";
}
if (id.includes("radix-vue") || id.includes("shadcn") || id.includes("lucide")) {
return "ui-components";
}
if (id.includes("primevue") || id.includes("@primevue")) {
return "primevue";
}
// CSS/build tools - group together (small)
if (id.includes("tailwind") || id.includes("postcss") || id.includes("autoprefixer") || id.includes("clsx")) {
return "css-utils";
}
// Everything else goes into vendor chunk
return "vendor";
}
}
}
}
};
// Only add terserOptions in production
if (isProduction) {
buildConfig.terserOptions = {
keep_classnames: true,
keep_fnames: true,
safari10: true, // Fix for Safari 10+ compatibility
compress: {
keep_classnames: true,
keep_fnames: true,
passes: 1, // Reduce passes to avoid breaking class inheritance
drop_console: false, // Keep console for debugging
// Disable ALL optimizations that could break class inheritance and dynamic function calls
collapse_vars: false,
reduce_vars: false,
inline: false,
unused: false, // Critical: don't remove unused code (might break dynamic imports)
dead_code: false, // Critical: don't remove dead code
conditionals: false, // Don't optimize conditionals
evaluate: false, // Don't evaluate constant expressions
loops: false, // Don't optimize loops
hoist_funs: false, // Don't hoist functions
hoist_vars: false, // Don't hoist variables
if_return: false, // Don't optimize if-return
join_vars: false, // Don't join var declarations
sequences: false, // Don't optimize sequences
properties: false, // Don't optimize property access
drop_debugger: false
},
mangle: false, // CRITICAL: Disable mangling completely to preserve all names
format: {
comments: false,
preserve_annotations: true,
ascii_only: false // Allow non-ASCII characters
}
};
}
return buildConfig;
})(),
server: {
fs: {
strict: true,
},
watch: {
ignored: [
'**/node_modules/**',
'**/.nuxt/**',
'**/.output/**',
'**/coverage/**',
'**/test-results/**',
'**/playwright-report/**',
'**/30000/**',
'**/.git/**',
'**/dist/**'
]
},
hmr: {
protocol: 'ws',
host: 'localhost',
overlay: true
}
}
},
plugins: [
{ src: '~/plugins/oh-vue-icons.js', mode: 'client' },
{ src: '~/plugins/highcharts.client.js', mode: 'client' },
],
routeRules: {
'/database': {
swr: true,
cache: {
maxAge: 60,
},
headers: {
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff',
'Referrer-Policy': 'strict-origin-when-cross-origin'
}
},
'/galaxy': {
ssr: false, // Client-side only for 3D visualization
headers: {
'X-Frame-Options': 'SAMEORIGIN',
'X-Content-Type-Options': 'nosniff'
}
},
},
app: {
head: {
charset: 'utf-8',
viewport: 'width=device-width, initial-scale=1',
title: 'ProcessorDB - CPU Database and Comparison',
meta: [
{ name: 'description', content: 'Comprehensive database of CPU specifications and comparisons' },
{ name: 'format-detection', content: 'telephone=no' },
{ property: 'og:title', content: 'ProcessorDB - CPU Database and Comparison' },
{ property: 'og:description', content: 'Comprehensive database of CPU specifications and comparisons' },
{ name: 'theme-color', content: '#ffffff' }
],
link: [
{ rel: "icon", type: "image/png", href: "/cpu.png", sizes: "32x32" }
]
}
},
build: {
transpile: ['oh-vue-icons']
},
nitro: {
compressPublicAssets: true,
serveStatic: true,
experimental: {
wasm: true
},
prerender: {
crawlLinks: false,
ignore: ['/api/**']
}
},
experimental: {
appManifest: false
},
compatibilityDate: "2024-10-15"
});