diff --git a/packages/webpack5/src/plugins/WatchStatePlugin.ts b/packages/webpack5/src/plugins/WatchStatePlugin.ts index 9adf2c6b0..81a8423f9 100644 --- a/packages/webpack5/src/plugins/WatchStatePlugin.ts +++ b/packages/webpack5/src/plugins/WatchStatePlugin.ts @@ -55,16 +55,24 @@ export class WatchStatePlugin { } // logic taken from CleanWebpackPlugin - const assets = - stats.toJson( - { - assets: true, - }, - true - ).assets || []; - const assetList = assets.map((asset) => asset.name); + // const assets = + // stats.toJson( + // { + // assets: true, + // }, + // true + // ).assets || []; + // const assetList = assets.map((asset) => asset.name); + // const emittedAssets = Array.from(compilation.emittedAssets); + + const assetList = Object.keys(compilation.assets); const emittedAssets = Array.from(compilation.emittedAssets); + + if (!prevAssets.length && emittedAssets.length < assetList.length) { + emittedAssets.push(...assetList); + } + const staleAssets = prevAssets.filter((asset) => { return assetList.includes(asset) === false; });