-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.base.ts
More file actions
102 lines (91 loc) · 2.93 KB
/
Copy pathvite.config.base.ts
File metadata and controls
102 lines (91 loc) · 2.93 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
/// <reference types="vitest" />
import { nxViteTsPaths } from "@nx/vite/plugins/nx-tsconfig-paths.plugin";
import { defineConfig } from "vite";
import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Workspace-level Vite configuration with Nx best practices
// This provides common configuration for all projects in the monorepo
export default defineConfig({
// Nx TypeScript paths plugin for proper module resolution
plugins: [nxViteTsPaths()],
// Path aliases for absolute imports
// Note: This is resolved dynamically relative to this config file
resolve: {
alias: {
"@": resolve(__dirname, "apps/web/src"),
},
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
},
// Common configuration that applies to all projects
server: {
host: true,
port: 4200,
},
build: {
target: "esnext",
sourcemap: true,
rollupOptions: {
onwarn(warning, warn) {
// Suppress certain warnings that are common in monorepos
if (warning.code === "MODULE_LEVEL_DIRECTIVE") return;
if (warning.code === "THIS_IS_UNDEFINED") return;
warn(warning);
},
// External dependencies for library builds
external: [
// React ecosystem
"react",
"react-dom",
"react/jsx-runtime",
// Mantine UI library
"@mantine/core",
"@mantine/hooks",
"@mantine/dates",
"@mantine/notifications",
"@mantine/spotlight",
// Icons and utilities
"@tabler/icons-react",
"@tanstack/react-table",
"@tanstack/react-router",
"@xyflow/react",
"date-fns",
"immer",
// Internal workspace dependencies
"@bibgraph/types",
"@bibgraph/utils",
],
output: {
globals: {
react: "React",
"react-dom": "ReactDOM",
"react/jsx-runtime": "jsxRuntime",
"@mantine/core": "MantineCore",
"@mantine/hooks": "MantineHooks",
"@mantine/dates": "MantineDates",
"@mantine/notifications": "MantineNotifications",
"@mantine/spotlight": "MantineSpotlight",
"@tabler/icons-react": "TablerIcons",
"@tanstack/react-table": "ReactTable",
"@tanstack/react-router": "ReactRouter",
"@xyflow/react": "XYFlow",
"date-fns": "dateFns",
immer: "immer",
},
},
},
},
// Optimized dependencies handling for monorepo
optimizeDeps: {
include: [],
// Handle Node.js externalization properly
exclude: ['@bibgraph/client', '@bibgraph/utils'],
},
// Define global replacements for browser compatibility
define: {
__DEV__: JSON.stringify(process.env.NODE_ENV !== "production"),
global: 'globalThis',
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
},
});