From 512a3d7bcee13038e8a27bc12a8d57bb46c4bf67 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sat, 25 Sep 2021 09:08:43 +0530 Subject: [PATCH] refactor: code --- lib/Server.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/Server.js b/lib/Server.js index b48a6eb57e..2ce4c52725 100644 --- a/lib/Server.js +++ b/lib/Server.js @@ -1993,20 +1993,10 @@ class Server { let isOutputModule = false; - if (typeof this.compiler.compilers !== "undefined") { - this.stats.stats.forEach((stats) => { - stats.compilation.assetsInfo.forEach((value, key) => { - const assetExtension = path.extname(key); - const assetBasename = path.basename(key, assetExtension); - - if (assetBasename === outputFilename) { - extension = assetExtension; - isOutputModule = value.javascriptModule; - } - }); - }); - } else { - this.stats.compilation.assetsInfo.forEach((value, key) => { + const stats = this.stats.stats ? this.stats.stats : [this.stats]; + + for (const item of stats) { + for (const [key, value] of item.compilation.assetsInfo) { const assetExtension = path.extname(key); const assetBasename = path.basename(key, assetExtension); @@ -2014,7 +2004,7 @@ class Server { extension = assetExtension; isOutputModule = value.javascriptModule; } - }); + } } if (isOutputModule) {