-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(@angular-devkit/build-angular): extract webpack configuratio…
…ns from browser builder
- Loading branch information
1 parent
f90a832
commit 528b7f1
Showing
5 changed files
with
68 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/angular_devkit/build_angular/src/webpack/configs/analytics.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* 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 } from '@angular-devkit/architect'; | ||
import { Configuration } from 'webpack'; | ||
import { WebpackConfigOptions } from '../../utils/build-options'; | ||
import { NgBuildAnalyticsPlugin } from '../plugins/analytics'; | ||
|
||
export function getAnalyticsConfig( | ||
wco: WebpackConfigOptions, | ||
context: BuilderContext, | ||
): Configuration { | ||
if (!context.analytics) { | ||
return {}; | ||
} | ||
|
||
// If there's analytics, add our plugin. Otherwise no need to slow down the build. | ||
let category = 'build'; | ||
if (context.builder) { | ||
// We already vetted that this is a "safe" package, otherwise the analytics would be noop. | ||
category = context.builder.builderName.split(':')[1] || context.builder.builderName || 'build'; | ||
} | ||
|
||
// The category is the builder name if it's an angular builder. | ||
return { | ||
plugins: [ | ||
new NgBuildAnalyticsPlugin( | ||
wco.projectRoot, | ||
context.analytics, | ||
category, | ||
!!wco.tsConfig.options.enableIvy, | ||
), | ||
], | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters