Skip to content

Commit aa0d89d

Browse files
committed
feat(@angular-devkit/build-angular): allow transformation of i18n extraction builder configuration
This change allows the underlying webpack configuration of the i18n extraction builder to be modified when programmatically using the builder. Programmatic usage of the `@angular-devkit/build-angular` builders is currently considered experimental.
1 parent 61701ab commit aa0d89d

File tree

1 file changed

+12
-4
lines changed
  • packages/angular_devkit/build_angular/src/extract-i18n

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from '../angular-cli-files/models/webpack-configs';
2626
import { statsErrorsToString, statsHasErrors, statsHasWarnings, statsWarningsToString } from '../angular-cli-files/utilities/stats';
2727
import { Schema as BrowserBuilderOptions } from '../browser/schema';
28+
import { ExecutionTransformer } from '../transforms';
2829
import { createI18nOptions } from '../utils/i18n-options';
2930
import { assertCompatibleAngularVersion } from '../utils/version';
3031
import { generateBrowserWebpackConfigFromContext } from '../utils/webpack-browser-config';
@@ -83,6 +84,9 @@ class InMemoryOutputPlugin {
8384
export async function execute(
8485
options: ExtractI18nBuilderOptions,
8586
context: BuilderContext,
87+
transforms?: {
88+
webpackConfiguration?: ExecutionTransformer<webpack.Configuration>;
89+
},
8690
): Promise<BuildResult> {
8791
// Check Angular version.
8892
assertCompatibleAngularVersion(context.workspaceRoot, context.logger);
@@ -226,10 +230,14 @@ export async function execute(
226230
}
227231
};
228232

229-
const webpackResult = await runWebpack(config, context, {
230-
logging,
231-
webpackFactory: await import('webpack'),
232-
}).toPromise();
233+
const webpackResult = await runWebpack(
234+
(await transforms?.webpackConfiguration?.(config)) || config,
235+
context,
236+
{
237+
logging,
238+
webpackFactory: await import('webpack'),
239+
},
240+
).toPromise();
233241

234242
// Complete if using VE
235243
if (!usingIvy) {

0 commit comments

Comments
 (0)