Skip to content

Commit 83fbaca

Browse files
clydinfilipesilva
authored andcommitted
fix(@angular-devkit/build-angular): correctly ignore inline styles during i18n extraction
Fixes #20968
1 parent c031de2 commit 83fbaca

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

packages/angular_devkit/build_angular/src/extract-i18n/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export async function execute(
240240
path.join(__dirname, 'empty-export-default.js'),
241241
),
242242
new webpack.NormalModuleReplacementPlugin(
243-
/^angular-resource:\/\//,
243+
/^angular-resource:style,/,
244244
path.join(__dirname, 'empty-export-default.js'),
245245
),
246246
],

packages/angular_devkit/build_angular/src/extract-i18n/works_spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,17 @@ describe('Extract i18n Target', () => {
146146
const fullLog = logs.join();
147147
expect(fullLog).toContain('Duplicate messages with id');
148148
});
149+
150+
it('ignores inline styles', async () => {
151+
host.appendToFile('src/app/app.component.html', '<p i18n>i18n test</p>');
152+
host.replaceInFile('src/app/app.component.ts', 'styleUrls', 'styles');
153+
host.replaceInFile('src/app/app.component.ts', './app.component.css', 'h1 { color: green; }');
154+
155+
const run = await architect.scheduleTarget(extractI18nTargetSpec);
156+
157+
// This will fail if a style is processed since the style rules are not included during extraction
158+
await expectAsync(run.result).toBeResolvedTo(jasmine.objectContaining({ success: true }));
159+
160+
await run.stop();
161+
});
149162
});

0 commit comments

Comments
 (0)