Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow multiple assets to map to the same file on disk #73

Closed
wants to merge 1 commit into from
Closed

allow multiple assets to map to the same file on disk #73

wants to merge 1 commit into from

Conversation

mxmul
Copy link

@mxmul mxmul commented Jun 14, 2020

Fixes #54. When using hashed filenames with file-loader, it's possible that two distinct resources in Webpack will map to the same file on disk (e.g. two copies of the same image). Currently, this plugin will only include one of them arbitrarily in the manifest.

I've switched around this.assetNames to map from original filename to hashed filename to allow all of these assets to appear in the manifest.

This change also resulted in some unexpected manifest entries, caused by the emitFile calls in mini-css-extract-plugin. It seems that the plugin always chose the first occurence of a file asset to intentionally skip over these (#39, #40), so I maintained this behavior by explicitly skipping all emitFile calls from mini-css-extract-plugin. This is admittedly a little jank, but it seems to work.

@mxmul mxmul requested a review from webdeveric as a code owner June 14, 2020 05:21
@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2020

Codecov Report

Merging #73 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #73   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          197       197           
=========================================
  Hits           197       197           
Impacted Files Coverage Δ
src/WebpackAssetsManifest.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 00477ac...e3f35c0. Read the comment docs.

@webdeveric
Copy link
Owner

@mxmul Thanks for the PR but I've already fixed this in my dev branch. I'll try to release an update soon.

@webdeveric webdeveric closed this Oct 25, 2020
@kedarv
Copy link

kedarv commented May 11, 2021

@webdeveric I'm think I might be seeing some related behavior on Webpack 5 and webpack-assets-manifest@5.0.6. Can you point me to the commit/option that has this fix in v5?

edit: whoops -- confirmed I'm not seeing this. but, still curious :)

@webdeveric
Copy link
Owner

@kedarv I think I fixed that in d382887. The findMapKeysByValue function is probably what you're looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If multiple assets map to the same output asset name, only one key is included
4 participants