1 | /// <reference types="node" />
|
2 |
|
3 | import { Plugin, ProgressPlugin } from "webpack";
|
4 |
|
5 | export = WebpackBar;
|
6 |
|
7 | /**
|
8 | * Elegant ProgressBar and Profiler for Webpack
|
9 | */
|
10 | declare class WebpackBar extends ProgressPlugin {
|
11 | constructor(options?: WebpackBar.Options);
|
12 | readonly state: WebpackBar.Status;
|
13 | }
|
14 |
|
15 | declare namespace WebpackBar {
|
16 | /**
|
17 | * 'context' is the reference to the plugin
|
18 | * You can use 'context.state' to access status
|
19 | */
|
20 | type ReporterContextFunc = (context: WebpackBar) => void;
|
21 |
|
22 | interface Status {
|
23 | /** @default null */
|
24 | readonly start: [number, number] | null;
|
25 | /** @default -1 */
|
26 | readonly progress: number;
|
27 | /** @default false */
|
28 | readonly done: boolean;
|
29 | /** @default '' */
|
30 | readonly message: string;
|
31 | readonly details: string[];
|
32 | readonly request: null | {
|
33 | readonly file: null | string;
|
34 | readonly loaders: string[];
|
35 | };
|
36 | /** @default false */
|
37 | readonly hasErrors: boolean;
|
38 | readonly color: string;
|
39 | readonly name: string;
|
40 | }
|
41 |
|
42 | /**
|
43 | * If you plan to provide your own reporter,
|
44 | * don't forget to setting fancy and basic options to false to prevent conflicts.
|
45 | * A reporter should be instance of a class or plain object and functions for special hooks.
|
46 | * It is not necessary to implement all functions, webpackbar only calls those that exists
|
47 | */
|
48 | interface Reporter {
|
49 | /**
|
50 | * Called when (re)compile is started
|
51 | */
|
52 | start?: ReporterContextFunc | undefined;
|
53 | /**
|
54 | * Called when a file changed on watch mode
|
55 | */
|
56 | change?: ReporterContextFunc | undefined;
|
57 | /**
|
58 | * Called after each progress update
|
59 | */
|
60 | update?: ReporterContextFunc | undefined;
|
61 | /**
|
62 | * Called when compile finished
|
63 | */
|
64 | done?: ReporterContextFunc | undefined;
|
65 | /**
|
66 | * Called when build progress updated
|
67 | */
|
68 | progress?: ReporterContextFunc | undefined;
|
69 | /**
|
70 | * Called when _all_ compiles finished
|
71 | */
|
72 | allDone?: ReporterContextFunc | undefined;
|
73 | beforeAllDone?: ReporterContextFunc | undefined;
|
74 | afterAllDone?: ReporterContextFunc | undefined;
|
75 | }
|
76 |
|
77 | interface Options {
|
78 | /**
|
79 | * Display name
|
80 | * @default 'webpack'
|
81 | */
|
82 | name?: string | undefined;
|
83 | /**
|
84 | * Color output of the progress bar
|
85 | * @default 'green'
|
86 | */
|
87 | color?: string | undefined;
|
88 |
|
89 | /**
|
90 | * Enable profiler
|
91 | * @default false
|
92 | */
|
93 | profile?: boolean | undefined;
|
94 | /**
|
95 | * Enable bars reporter
|
96 | * Defaults to 'true' when not in CI or testing mod
|
97 | * @default true
|
98 | */
|
99 | fancy?: boolean | undefined;
|
100 | /**
|
101 | * Enable a simple log reporter (only start and end)
|
102 | * Defaults to 'true' when running in minimal environments
|
103 | * @default true
|
104 | */
|
105 | basic?: boolean | undefined;
|
106 | /**
|
107 | * Register a custom reporter
|
108 | * @default null
|
109 | */
|
110 | reporter?: Reporter | null | undefined;
|
111 | /**
|
112 | * Register an Array of your custom reporters.
|
113 | * @default ['basic'] | ['fancy']
|
114 | */
|
115 | reporters?: string[] | undefined;
|
116 | }
|
117 | }
|