-
Notifications
You must be signed in to change notification settings - Fork 12k
/
Copy pathprogress-plugin.ts
38 lines (34 loc) · 1.18 KB
/
progress-plugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @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 { ProgressPlugin as WebpackProgressPlugin } from 'webpack';
import { Spinner } from '../../../utils/spinner';
export class ProgressPlugin extends WebpackProgressPlugin {
constructor(platform: 'server' | 'browser') {
const platformCapitalFirst = platform.replace(/^\w/, (s) => s.toUpperCase());
const spinner = new Spinner();
spinner.start(`Generating ${platform} application bundles (phase: setup)...`);
super({
handler: (percentage: number, message: string) => {
const phase = message ? ` (phase: ${message})` : '';
spinner.text = `Generating ${platform} application bundles${phase}...`;
switch (percentage) {
case 1:
if (spinner.isSpinning) {
spinner.succeed(`${platformCapitalFirst} application bundle generation complete.`);
}
break;
case 0:
if (!spinner.isSpinning) {
spinner.start();
}
break;
}
},
});
}
}