import type webpack from "webpack"; import { styleText } from "node:util"; /** * Плагин для завершения сборки * @example * import { FinishPlugin } from "@delement/ui/utils/webpack"; * * const plugins = [ new FinishPlugin({ isExitInCI: true }) ]; */ export default class FinishPlugin { private readonly isShouldExit: boolean; constructor(options?: { isExitInCI?: boolean; }) { this.isShouldExit = options?.isExitInCI || false; } apply(compiler: webpack.Compiler) { compiler.hooks.done.tap(this.constructor.name, () => { if (this.isShouldExit) { console.debug(styleText("green", `[${this.constructor.name}] Frontend build are ready`)); setTimeout(() => { process.exit(0); }); } }); } }