diff --git a/src/BuildTimeReport.ts b/src/BuildTimeReport.ts index bb265ef..c5936be 100644 --- a/src/BuildTimeReport.ts +++ b/src/BuildTimeReport.ts @@ -1,11 +1,11 @@ import webpack from 'webpack'; -import { BuildTimeReporterStats, Step, StepStats } from './types'; +import { AssetStats, BuildTimeReporterStats, Step, StepStats } from './types'; export class BuildTimeReport { private readonly steps = new Map(); private timeStart = 0; private timeEnd = 0; - private assets: string[] = []; + private assets: AssetStats[] = []; private chunks: string[] = []; private modules: string[] = []; private hash?: string; @@ -41,7 +41,10 @@ export class BuildTimeReport { this.assets = []; Object.entries(assets).forEach(([assetName, asset]) => { if (asset.emitted) { - this.assets.push(assetName); + this.assets.push({ + name: assetName, + size: asset.info.size!, + }); } }); } @@ -73,6 +76,7 @@ export class BuildTimeReport { initialResource: this.initialResource, rebuild: this.rebuild, nodeEnv: process.env.NODE_ENV as string, + assets: this.assets, }; } diff --git a/src/types.ts b/src/types.ts index f72cc00..58b3cfd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,5 @@ export interface BuildTimeReporterWebpackPluginOptions { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - report: (stats: BuildTimeReporterStats) => Promise; + report: (stats: BuildTimeReporterStats) => Promise; } export interface StepStats { @@ -9,6 +8,11 @@ export interface StepStats { duration: number; } +export interface AssetStats { + name: string; + size: number; +} + export type Step = 'build' | 'optimize' | 'emit'; export interface BuildTimeReporterStats { @@ -23,4 +27,5 @@ export interface BuildTimeReporterStats { initialResource?: string; rebuild: boolean; nodeEnv: string; + assets: AssetStats[]; }