From 88467b3b659f2ae6a34f2214705d2dec4c046c76 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:02:17 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): disable Webpack 5 automatic public path support The Webpack 5 automatic public path support can cause an incorrect public path to be used to load assets and lazy loaded routes. The current logic relies on the last script element found at runtime in the application's index HTML which may not be related to the application scripts. Now if a `deployUrl` is not specified, the Webpack `publicPath` option is defaulted to an empty string which provides equivalent behavior to Webpack 4. (cherry picked from commit e107055b6f459b75468e1faf512ca489bede989f) --- .../angular_devkit/build_angular/src/webpack/configs/common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/webpack/configs/common.ts b/packages/angular_devkit/build_angular/src/webpack/configs/common.ts index c050e894e784..2508c545576b 100644 --- a/packages/angular_devkit/build_angular/src/webpack/configs/common.ts +++ b/packages/angular_devkit/build_angular/src/webpack/configs/common.ts @@ -432,7 +432,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { entry: entryPoints, output: { path: path.resolve(root, buildOptions.outputPath), - publicPath: buildOptions.deployUrl, + publicPath: buildOptions.deployUrl ?? '', filename: ({ chunk }) => { if (chunk?.name === 'polyfills-es5') { return `polyfills-es5${hashFormat.chunk}.js`;