Skip to content

Commit

Permalink
Reset the outputNormal object to avoid duplicate files
Browse files Browse the repository at this point in the history
  • Loading branch information
chihsuan committed Feb 23, 2024
1 parent 1c0d6c6 commit 0c4688d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/woocommerce-admin/unminify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* 2. Remove check for development mode - we always want unminified files.
* 3. Remove BannerPlugin support - we don't use it.
* 4. Remove the 'min' suffix from the chunk loaded in the new `mainEntry` option.
* 5. Hook into compilation later so we're running after Source Map generation. (https://webpack.js.org/api/compilation-hooks/: PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE)
* 5. Hook into compilation later so we're running after Source Map generation. (https://webpack.js.org/api/compilation-hooks/: PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE)
*/
const path = require( 'path' );
const ModuleFilenameHelpers = require( 'webpack/lib/ModuleFilenameHelpers' );
Expand Down Expand Up @@ -39,7 +39,7 @@ class UnminifyWebpackPlugin {

apply( compiler ) {
const options = this.options;
const outputNormal = {};
let outputNormal = {};

compiler.hooks.compilation.tap(
'UnminifyWebpackPlugin',
Expand All @@ -60,7 +60,6 @@ class UnminifyWebpackPlugin {
) {
return;
}

let sourceCode = source.source();
if (
options.mainEntry &&
Expand All @@ -81,7 +80,6 @@ class UnminifyWebpackPlugin {
options
)
);

outputNormal[ outputPath ] = {
filename: getFileName(
pathname,
Expand All @@ -107,6 +105,8 @@ class UnminifyWebpackPlugin {
value.filename,
new webpack.sources.RawSource( value.content )
);
// Reset the outputNormal object to avoid writing to file that only differs in casing or query string from already written file.
outputNormal = {};
}
}
);
Expand Down

0 comments on commit 0c4688d

Please sign in to comment.