import Fs from 'fs' ; import Path from 'path' ; import webpack from 'webpack' ; import { Bundle } from '../common' ; export class EmitStatsPlugin { constructor ( private readonly bundle ) { } public apply ( compiler ) { compiler . hooks . done . tap ( { name : 'EmitStatsPlugin' , stage : 10 , } , ( stats ) => { Fs . writeFileSync ( Path . resolve ( this . bundle . outputDir , 'stats.json' ) , JSON . stringify ( stats . toJson ( ) , null , 2 ) ) ; } ) ; } }