Skip to content

Commit f2d26f5

Browse files
GeekTrainerCopilot
andcommitted
Fix Vite serving errors for symlinked node_modules
Dynamically detect when node_modules is a symlink and add the real path to Vite's server.fs.allow list. This resolves dev toolbar errors in environments with symlinked dependencies while remaining a no-op when node_modules is not symlinked. Add esbuild-wasm as a dependency. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1d58a16 commit f2d26f5

3 files changed

Lines changed: 6483 additions & 0 deletions

File tree

app/client/astro.config.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// @ts-check
2+
process.env.ASTRO_TELEMETRY_DISABLED = '1';
3+
import { defineConfig } from 'astro/config';
4+
import tailwindcss from '@tailwindcss/vite';
5+
import node from '@astrojs/node';
6+
import fs from 'node:fs';
7+
import path from 'node:path';
8+
9+
// Allow Vite to serve files from the real node_modules path when it is symlinked
10+
const nodeModulesPath = path.resolve('node_modules');
11+
const realNodeModulesPath = fs.realpathSync(nodeModulesPath);
12+
const fsAllow = ['..'];
13+
if (realNodeModulesPath !== nodeModulesPath) {
14+
fsAllow.push(path.dirname(realNodeModulesPath));
15+
}
16+
17+
// https://astro.build/config
18+
export default defineConfig({
19+
output: 'server',
20+
vite: {
21+
plugins: [tailwindcss()],
22+
server: {
23+
fs: {
24+
allow: fsAllow,
25+
},
26+
},
27+
},
28+
adapter: node({
29+
mode: 'standalone'
30+
}),
31+
});

0 commit comments

Comments
 (0)