Skip to content

Commit 06eb365

Browse files
committed
feat(web): configure @nx/vite:dev-server with proper pnpm workspace support
- Add proper build target using @nx/vite:build executor with root configuration - Update serve target to use @nx/vite:dev-server with correct buildTarget - Configure Vite file system access for pnpm workspaces (server.fs.allow) - Fix optimizeDeps to exclude problematic Nx runtime dependencies - Add React 19 compatibility with jsx-runtime dependencies - Enable React deduplication to prevent version conflicts - Remove barrelsby dependency from lockfile This enables native Nx Vite development server with improved integration and better performance over the previous workaround. Both `nx serve web` and `pnpm dev` now use @nx/vite:dev-server successfully.
1 parent 6ea7cad commit 06eb365

File tree

3 files changed

+49
-32
lines changed

3 files changed

+49
-32
lines changed

apps/web/project.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,36 @@
1111
"cwd": "{projectRoot}"
1212
}
1313
},
14+
"build": {
15+
"executor": "@nx/vite:build",
16+
"defaultConfiguration": "production",
17+
"options": {
18+
"outputPath": "dist/apps/web",
19+
"root": "apps/web"
20+
},
21+
"configurations": {
22+
"development": {
23+
"mode": "development"
24+
},
25+
"production": {
26+
"mode": "production"
27+
}
28+
}
29+
},
1430
"serve": {
15-
"executor": "nx:run-commands",
31+
"executor": "@nx/vite:dev-server",
32+
"defaultConfiguration": "development",
1633
"options": {
17-
"command": "cd apps/web && vite",
18-
"cwd": "{workspaceRoot}"
34+
"buildTarget": "web:build",
35+
"configFile": "apps/web/vite.config.ts"
1936
},
2037
"configurations": {
38+
"development": {
39+
"buildTarget": "web:build:development"
40+
},
2141
"production": {
22-
"command": "cd apps/web && vite build --mode production && vite preview --port 4173"
42+
"buildTarget": "web:build:production",
43+
"mode": "production"
2344
}
2445
}
2546
},

apps/web/vite.config.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ function createWebConfig(): UserConfig {
163163
alias: {
164164
'@': resolve(__dirname, 'src'),
165165
},
166+
dedupe: ['react', 'react-dom'],
166167
},
167168

168169
// Development server configuration
@@ -175,7 +176,14 @@ function createWebConfig(): UserConfig {
175176
port: 5174,
176177
},
177178
fs: {
178-
strict: true,
179+
strict: false,
180+
allow: [
181+
'.', // Current project
182+
'..', // Parent directory
183+
'../..', // For accessing sibling projects
184+
'../../.pnpm', // For pnpm store access
185+
'../../node_modules' // For workspace dependencies
186+
],
179187
},
180188
watch: {
181189
usePolling: false,
@@ -196,6 +204,9 @@ function createWebConfig(): UserConfig {
196204
include: [
197205
'react',
198206
'react-dom',
207+
'react/jsx-runtime',
208+
'react/jsx-dev-runtime',
209+
'react-dom/client',
199210
'@tanstack/react-router',
200211
'@tanstack/react-query',
201212
'@mantine/core',
@@ -204,8 +215,18 @@ function createWebConfig(): UserConfig {
204215
exclude: [
205216
'@bibgraph/client',
206217
'@bibgraph/utils',
218+
'@nx/vite',
219+
'@nx/vite/plugin',
220+
'@nx/devkit',
221+
'@nx/angular',
222+
'rxjs',
223+
'@angular-devkit/architect',
224+
'@angular-devkit/core',
225+
'@angular-devkit/schematics',
226+
'ts-node',
227+
'@swc-node/register'
207228
],
208-
force: true,
229+
force: false,
209230
},
210231

211232
// Define global replacements

pnpm-lock.yaml

Lines changed: 1 addition & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)