UNPKG

1.01 kBPlain TextView Raw
1import * as webpack from "webpack";
2import {Logger} from "@simplism/core";
3
4export class FriendlyLoggerPlugin implements webpack.Plugin {
5 public constructor(private readonly _options: {
6 logger: Logger;
7 packageName: string;
8 }) {
9 }
10
11 public apply(compiler: webpack.Compiler): void {
12 compiler.hooks.run.tap("FriendlyLoggerPlugin", () => {
13 this._options.logger.log(`빌드...`);
14 });
15
16 compiler.hooks.watchRun.tap("FriendlyLoggerPlugin", () => {
17 this._options.logger.log(`빌드...`);
18 });
19
20 compiler.hooks.done.tap("FriendlyLoggerPlugin", stats => {
21 const info = stats.toJson();
22
23 if (stats.hasWarnings()) {
24 for (const warning of info.warnings) {
25 this._options.logger.warn(warning);
26 }
27 }
28
29 if (stats.hasErrors()) {
30 for (const error of info.errors) {
31 this._options.logger.error(error);
32 }
33 }
34
35 this._options.logger.info(`빌드 완료`);
36 });
37 }
38}
\No newline at end of file