Skip to content

Commit

Permalink
feat(@angular-devkit/build-angular): allow transformation of i18n ext…
Browse files Browse the repository at this point in the history
…raction 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.

Closes #16679
  • Loading branch information
clydin committed Aug 26, 2020
1 parent 301d926 commit 802d5ad
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/angular_devkit/build_angular/src/extract-i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '../angular-cli-files/models/webpack-configs';
import { statsErrorsToString, statsHasErrors, statsHasWarnings, statsWarningsToString } from '../angular-cli-files/utilities/stats';
import { Schema as BrowserBuilderOptions } from '../browser/schema';
import { ExecutionTransformer } from '../transforms';
import { createI18nOptions } from '../utils/i18n-options';
import { assertCompatibleAngularVersion } from '../utils/version';
import { generateBrowserWebpackConfigFromContext } from '../utils/webpack-browser-config';
Expand Down Expand Up @@ -83,6 +84,9 @@ class InMemoryOutputPlugin {
export async function execute(
options: ExtractI18nBuilderOptions,
context: BuilderContext,
transforms?: {
webpackConfiguration?: ExecutionTransformer<webpack.Configuration>;
},
): Promise<BuildResult> {
// Check Angular version.
assertCompatibleAngularVersion(context.workspaceRoot, context.logger);
Expand Down Expand Up @@ -226,10 +230,14 @@ export async function execute(
}
};

const webpackResult = await runWebpack(config, context, {
logging,
webpackFactory: await import('webpack'),
}).toPromise();
const webpackResult = await runWebpack(
(await transforms?.webpackConfiguration?.(config)) || config,
context,
{
logging,
webpackFactory: await import('webpack'),
},
).toPromise();

// Complete if using VE
if (!usingIvy) {
Expand Down

0 comments on commit 802d5ad

Please sign in to comment.