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MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;iBACxF,OAAO,CAAC,CAAC,CAAC;iBACV,QAAQ,CAAC,CAAC,CAAC,KAAK,YAAY,CAAC,GAAG,CAAC,IAAI,OAAO,EAAE,CAClD,CAAC;YACF,cAAc,GAAG,GAAG,CAAC;YACrB,cAAc,GAAG,UAAU,CAAC;SAC7B;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { relative } from \"path\";\r\nimport webpack from \"webpack\";\r\n\r\nexport function progressPlugin() {\r\n let currentMessage: string | null = null;\r\n let lastPercentage = 0;\r\n\r\n const startTime = Date.now();\r\n\r\n const messageSteps = {\r\n compiling: \"Compilation started\",\r\n building: \"Building\",\r\n \"finish module graph\": \"Finishing module graph\",\r\n optimizing: \"Running optimizations\",\r\n hashing: \"Hashing\",\r\n \"chunk asset optimization\": \"Minimizing\",\r\n \"after chunk asset optimization\": \"Creating source maps\",\r\n emitting: \"Emitting files\"\r\n };\r\n return new webpack.ProgressPlugin((percentage, msg, ...args) => {\r\n // if (msg !== \"building\") {\r\n // console.log({ percentage, msg, args });\r\n // }\r\n if (!Object.keys(messageSteps).includes(msg)) {\r\n return;\r\n }\r\n if (currentMessage !== msg || Math.abs(lastPercentage - percentage) > 0.07) {\r\n let postfix: string = \"\";\r\n if (msg === \"building\") {\r\n postfix = ` - ${args[0]} ${args[1]}`;\r\n } /*else {\r\n console.log({ percentage, msg, args });\r\n }*/\r\n console.log(\r\n ` ${`[${((Date.now() - startTime) / 1000).toFixed(2)} s]`.padEnd(10)} ${(percentage * 100)\r\n .toFixed(0)\r\n .padStart(3)}% ${messageSteps[msg]} ${postfix}`\r\n );\r\n currentMessage = msg;\r\n lastPercentage = percentage;\r\n }\r\n });\r\n}\r\n"]}
\No newline at end of file