mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 23:15:56 +08:00
In https://github.com/angular/angular-cli/pull/25070 we turned on `buildOptimizer` by default for server builds. This causes existing projects development builds to always run build-optimizer. This migration will set `buildOptimizer` to false, when `optimization` is disabled.
31 lines
990 B
TypeScript
31 lines
990 B
TypeScript
/**
|
|
* @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 { Rule } from '@angular-devkit/schematics';
|
|
import { allTargetOptions, updateWorkspace } from '../../utility/workspace';
|
|
import { Builders } from '../../utility/workspace-models';
|
|
|
|
export default function (): Rule {
|
|
return updateWorkspace((workspace) => {
|
|
for (const project of workspace.projects.values()) {
|
|
for (const target of project.targets.values()) {
|
|
if (target.builder !== Builders.Server) {
|
|
continue;
|
|
}
|
|
|
|
for (const [, options] of allTargetOptions(target)) {
|
|
// Set 'buildOptimizer' to match the 'optimization' option.
|
|
if (options.buildOptimizer === undefined && options.optimization !== undefined) {
|
|
options.buildOptimizer = !!options.optimization;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|