mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-18 11:44:05 +08:00
Adds the new flag `--build-optimizer` (`--bo`), usable only with `--aot` (or `--prod` since it auto enables `--aot`). This feature is experimental, and may not work correctly on your project. Should it work, total bundle size should go down. Savings are heavily dependent on the project. See https://github.com/angular/devkit/tree/master/packages/angular_devkit/build_optimizer for details about all the optimizations applied. Usage: `ng build --prod --build-optimizer`. Disabling the vendor chunk has been shown to improve total savings, and is done automatically when `--bo` is specified unless `--vendor-chunk` has a value. Please let us know if using `--build-optimizer` breaks your project so we can improve it further. Repos are very welcome.
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { BuildOptions } from '../models/build-options';
|
|
import {baseBuildCommandOptions} from './build';
|
|
|
|
const Command = require('../ember-cli/lib/models/command');
|
|
|
|
// defaults for BuildOptions
|
|
export const baseEjectCommandOptions: any = [
|
|
...baseBuildCommandOptions,
|
|
{
|
|
name: 'force',
|
|
type: Boolean,
|
|
description: 'Overwrite any webpack.config.js and npm scripts already existing.'
|
|
},
|
|
{
|
|
name: 'app',
|
|
type: String,
|
|
aliases: ['a'],
|
|
description: 'Specifies app name to use.'
|
|
}
|
|
];
|
|
|
|
export interface EjectTaskOptions extends BuildOptions {
|
|
force?: boolean;
|
|
app?: string;
|
|
}
|
|
|
|
|
|
const EjectCommand = Command.extend({
|
|
name: 'eject',
|
|
description: 'Ejects your app and output the proper webpack configuration and scripts.',
|
|
|
|
availableOptions: baseEjectCommandOptions,
|
|
|
|
run: function (commandOptions: EjectTaskOptions) {
|
|
|
|
// Default vendor chunk to false when build optimizer is on.
|
|
if (commandOptions.vendorChunk === undefined) {
|
|
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
|
|
}
|
|
|
|
const EjectTask = require('../tasks/eject').default;
|
|
const ejectTask = new EjectTask({
|
|
project: this.project,
|
|
ui: this.ui,
|
|
});
|
|
|
|
return ejectTask.run(commandOptions);
|
|
}
|
|
});
|
|
|
|
|
|
export default EjectCommand;
|