Skip to content

Commit a7cf22c

Browse files
alan-agius4dgp1130
authored andcommittedMay 5, 2020
feat(@schematics/angular): add stricter bundle budgets when using the --strict option
When using the strict option `anyComponentStyle` and `initial` budgets are more strict.
1 parent cbf0feb commit a7cf22c

File tree

1 file changed

+29
-11
lines changed
  • packages/schematics/angular/application

1 file changed

+29
-11
lines changed
 

‎packages/schematics/angular/application/index.ts

+29-11
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,34 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul
179179
}
180180

181181
const sourceRoot = join(normalize(projectRoot), 'src');
182+
let budgets = [];
183+
if (options.strict) {
184+
budgets = [
185+
{
186+
type: 'initial',
187+
maximumWarning: '500kb',
188+
maximumError: '1mb',
189+
},
190+
{
191+
type: 'anyComponentStyle',
192+
maximumWarning: '2kb',
193+
maximumError: '4kb',
194+
},
195+
];
196+
} else {
197+
budgets = [
198+
{
199+
type: 'initial',
200+
maximumWarning: '2mb',
201+
maximumError: '5mb',
202+
},
203+
{
204+
type: 'anyComponentStyle',
205+
maximumWarning: '6kb',
206+
maximumError: '10kb',
207+
},
208+
];
209+
}
182210

183211
const project = {
184212
root: normalize(projectRoot),
@@ -219,17 +247,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul
219247
extractLicenses: true,
220248
vendorChunk: false,
221249
buildOptimizer: true,
222-
budgets: [
223-
{
224-
type: 'initial',
225-
maximumWarning: '2mb',
226-
maximumError: '5mb',
227-
},
228-
{
229-
type: 'anyComponentStyle',
230-
maximumWarning: '6kb',
231-
maximumError: '10kb',
232-
}],
250+
budgets,
233251
},
234252
},
235253
},

0 commit comments

Comments
 (0)