統計情報フック

StatsFactory

StatsFactory.hooks.extract

指定された統計項目を生成する際に呼び出されるHookMapです。

  • 型: HookMap<SyncBailHook<[Object, any, StatsFactoryContext], undefined>>
  • 引数
    • Object: プロパティを追加する必要がある結果の統計項目オブジェクト。
    • Class: 統計項目の元のデータ
    • StatsFactoryContext: 生成コンテキスト
type StatsFactoryContext = {
  type: string;
  makePathsRelative?: ((arg0: string) => string) | undefined;
  compilation?: Compilation | undefined;
  cachedGetErrors?: ((arg0: Compilation) => JsStatsError[]) | undefined;
  cachedGetWarnings?: ((arg0: Compilation) => JsStatsWarning[]) | undefined;
};

以下の例では、`MyPlugin` を介して最終的に生成された `stats.compilation` に `customProperty` 属性が追加されます。

compilation.hooks.statsFactory.tap('MyPlugin', (statsFactory, options) => {
  statsFactory.hooks.extract
    .for('compilation')
    .tap('MyPlugin', (object, compilation) => {
      object.customProperty = MyPlugin.getCustomValue(compilation);
    });
});

StatsFactory.hooks.result

指定された統計項目を生成した後に呼び出されるHookMapです。

  • 型: HookMap<SyncWaterfallHook<[any[], StatsFactoryContext], undefined>>
  • 引数
    • any[]: 生成された統計項目の結果
    • StatsFactoryContext: 生成コンテキスト

StatsPrinter

StatsPrinter.hooks.print

呼び出されるHookMapです。

指定された統計項目の出力文字列を生成する際に呼び出されるHookMapです。

  • 型: HookMap<SyncBailHook<[{}, StatsPrinterContext], string>>
  • 引数
    • Object: 統計項目オブジェクト
    • StatsPrinterContext: 出力コンテキスト
type StatsPrinterContext = {
  type?: string;
  compilation?: StatsCompilation;
  chunkGroup?: StatsChunkGroup;
  asset?: StatsAsset;
  module?: StatsModule;
  chunk?: StatsChunk;
  moduleReason?: StatsModuleReason;
  bold?: (str: string) => string;
  yellow?: (str: string) => string;
  red?: (str: string) => string;
  green?: (str: string) => string;
  magenta?: (str: string) => string;
  cyan?: (str: string) => string;
  formatFilename?: (file: string, oversize?: boolean) => string;
  formatModuleId?: (id: string) => string;
  formatChunkId?:
    | ((id: string, direction?: 'parent' | 'child' | 'sibling') => string)
    | undefined;
  formatSize?: (size: number) => string;
  formatDateTime?: (dateTime: number) => string;
  formatFlag?: (flag: string) => string;
  formatTime?: (time: number, boldQuantity?: boolean) => string;
  chunkGroupKind?: string;
};

StatsPrinter.hooks.result

指定された統計項目の出力文字列を生成した後に呼び出されるHookMapです。

  • 型: HookMap<SyncBailHook<[{}, StatsPrinterContext], string>>
  • 引数
    • String: 統計項目の出力文字列
    • StatsPrinterContext: 出力コンテキスト