Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 95dba95

Browse files
committedNov 17, 2023
fix(@angular-devkit/build-angular): ensure all configured assets can be served by dev server
The Vite-based development server restricts filesystem access by default. However, assets configured by the build option `assets` are intended to be accessible by the application at runtime. To ensure that these files are accessible, the allow list will now explicitly include all configured assets found during the build.
1 parent a4f32cd commit 95dba95

File tree

1 file changed

+9
-1
lines changed
  • packages/angular_devkit/build_angular/src/builders/dev-server

1 file changed

+9
-1
lines changed
 

‎packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,10 +425,11 @@ export async function setupServer(
425425
...externalMetadata.explicit,
426426
];
427427

428+
const cacheDir = join(serverOptions.cacheOptions.path, 'vite');
428429
const configuration: InlineConfig = {
429430
configFile: false,
430431
envFile: false,
431-
cacheDir: join(serverOptions.cacheOptions.path, 'vite'),
432+
cacheDir,
432433
root: virtualProjectRoot,
433434
publicDir: false,
434435
esbuild: false,
@@ -453,6 +454,13 @@ export async function setupServer(
453454
watch: {
454455
ignored: ['**/*'],
455456
},
457+
fs: {
458+
// Ensure cache directory, node modules, and all assets are accessible by the client.
459+
// The first two are required for Vite to function in prebundling mode (the default) and to load
460+
// the Vite client-side code for browser reloading. These would be available by default but when
461+
// the `allow` option is explicitly configured, they must be included manually.
462+
allow: [cacheDir, join(serverOptions.workspaceRoot, 'node_modules'), ...assets.values()],
463+
},
456464
// This is needed when `externalDependencies` is used to prevent Vite load errors.
457465
// NOTE: If Vite adds direct support for externals, this can be removed.
458466
preTransformRequests: externalMetadata.explicit.length === 0,

0 commit comments

Comments
 (0)
Please sign in to comment.