Skip to content

Commit d09605b

Browse files
committed
add server config for linked mode sandboxes
1 parent 0d8b963 commit d09605b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scripts/tasks/sandbox-parts.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,15 @@ export async function setupVitest(details: TemplateDetails, options: PassedOptio
543543
// Insert resolve after plugins
544544
return `${match}\n resolve: {\n preserveSymlinks: true\n },`;
545545
});
546+
547+
// In linked mode, add server.fs.allow to allow Vite to serve files from the monorepo root
548+
if (options.link) {
549+
fileContent = fileContent.replace(/(plugins\s*:\s*\[[^\]]*\],?)/, (match) => {
550+
// Insert server.fs.allow after plugins (alongside resolve)
551+
return `${match}\n server: {\n fs: {\n allow: ['../../..']\n }\n },`;
552+
});
553+
}
554+
546555
// search for storybookTest({...}) and place `tags: 'vitest'` into it but tags option doesn't exist yet in the config. Also consider multi line
547556
const storybookTestRegex = /storybookTest\((\{[\s\S]*?\})\)/g;
548557
fileContent = fileContent.replace(storybookTestRegex, (match, args) => {

0 commit comments

Comments
 (0)