From 9bbb6ed3e6892a4d50af71bea59986544c4e08c5 Mon Sep 17 00:00:00 2001 From: Sachin Grover Date: Wed, 26 Feb 2020 23:31:50 +0530 Subject: [PATCH] fix(@angular-devkit/build-angular): allow function in filename while changing the name of compiling chunks Fixes angular#17087 (cherry picked from commit 14dc4fb818815884d06896b5b5f5a219b64ef366) --- .../src/angular-cli-files/models/webpack-configs/common.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts b/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts index 0d6ee7723cc6..5815f6f916d3 100644 --- a/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts +++ b/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts @@ -149,12 +149,13 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { // tslint:disable-next-line: no-any (compilation.mainTemplate.hooks as any).assetPath.tap( 'build-angular', - (filename: string, data: ChunkData) => { - const isMap = filename && filename.endsWith('.map'); + (filename: string | ((data: ChunkData) => string), data: ChunkData) => { + const assetName = typeof filename === 'function' ? filename(data) : filename; + const isMap = assetName && assetName.endsWith('.map'); return data.chunk && data.chunk.name === 'polyfills-es5' ? `polyfills-es5${hashFormat.chunk}.js${isMap ? '.map' : ''}` - : filename; + : assetName; }, ); });