Skip to content

Commit

Permalink
feat(@angular-devkit/build-angular): use builder name for category
Browse files Browse the repository at this point in the history
So we can differentiate between dev-server, browser, karma, etc.
  • Loading branch information
hansl authored and alexeagle committed Mar 28, 2019
1 parent 1f9f92e commit 00fb4ce
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/angular_devkit/build_angular/src/browser/index2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect/src/index2';
import {
BuilderContext,
BuilderInfo,
BuilderOutput,
createBuilder,
} from '@angular-devkit/architect/src/index2';
import {
WebpackLoggingCallback,
runWebpack,
Expand Down Expand Up @@ -93,6 +98,7 @@ export function buildWebpackConfig(
additionalOptions: {
logger?: logging.LoggerApi,
analytics?: analytics.Analytics,
builderInfo?: BuilderInfo,
} = {},
): webpack.Configuration {
// Ensure Build Optimizer is only used with AOT.
Expand Down Expand Up @@ -135,9 +141,15 @@ export function buildWebpackConfig(

if (additionalOptions.analytics) {
// If there's analytics, add our plugin. Otherwise no need to slow down the build.
let category = 'build';
if (additionalOptions.builderInfo) {
// We already vetted that this is a "safe" package, otherwise the analytics would be noop.
category = additionalOptions.builderInfo.builderName.split(':')[1];
}
// The category is the builder name if it's an angular builder.
webpackConfigs.push({
plugins: [
new NgBuildAnalyticsPlugin(wco.projectRoot, additionalOptions.analytics, 'build'),
new NgBuildAnalyticsPlugin(wco.projectRoot, additionalOptions.analytics, category),
],
});
}
Expand Down Expand Up @@ -172,6 +184,7 @@ export async function buildBrowserWebpackConfigFromWorkspace(
additionalOptions: {
logger?: logging.LoggerApi,
analytics?: analytics.Analytics,
builderInfo?: BuilderInfo,
} = {},
): Promise<webpack.Configuration> {
// TODO: Use a better interface for workspace access.
Expand Down Expand Up @@ -218,6 +231,7 @@ export async function buildBrowserWebpackConfigFromContext(
{
logger: context.logger,
analytics: context.analytics,
builderInfo: context.builder,
},
);

Expand Down

0 comments on commit 00fb4ce

Please sign in to comment.