From 8854b4cded013e8918269053bb6fc702307e6f49 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 27 May 2021 11:49:20 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): correctly ignore inline styles during i18n extraction Fixes #20968 --- .../build_angular/src/extract-i18n/index.ts | 2 +- .../build_angular/src/extract-i18n/works_spec.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/extract-i18n/index.ts b/packages/angular_devkit/build_angular/src/extract-i18n/index.ts index cf2922bb9174..0e2d8919a72d 100644 --- a/packages/angular_devkit/build_angular/src/extract-i18n/index.ts +++ b/packages/angular_devkit/build_angular/src/extract-i18n/index.ts @@ -240,7 +240,7 @@ export async function execute( path.join(__dirname, 'empty-export-default.js'), ), new webpack.NormalModuleReplacementPlugin( - /^angular-resource:\/\//, + /^angular-resource:style,/, path.join(__dirname, 'empty-export-default.js'), ), ], diff --git a/packages/angular_devkit/build_angular/src/extract-i18n/works_spec.ts b/packages/angular_devkit/build_angular/src/extract-i18n/works_spec.ts index 55a4b7c255d7..7989d77fe748 100644 --- a/packages/angular_devkit/build_angular/src/extract-i18n/works_spec.ts +++ b/packages/angular_devkit/build_angular/src/extract-i18n/works_spec.ts @@ -146,4 +146,17 @@ describe('Extract i18n Target', () => { const fullLog = logs.join(); expect(fullLog).toContain('Duplicate messages with id'); }); + + it('ignores inline styles', async () => { + host.appendToFile('src/app/app.component.html', '

i18n test

'); + host.replaceInFile('src/app/app.component.ts', 'styleUrls', 'styles'); + host.replaceInFile('src/app/app.component.ts', './app.component.css', 'h1 { color: green; }'); + + const run = await architect.scheduleTarget(extractI18nTargetSpec); + + // This will fail if a style is processed since the style rules are not included during extraction + await expectAsync(run.result).toBeResolvedTo(jasmine.objectContaining({ success: true })); + + await run.stop(); + }); });