-
-
Notifications
You must be signed in to change notification settings - Fork 608
Avoid hash collisions by default with random hashPrefix? #413
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
Comments
Running into the same issue. Any advice would be much appreciated. |
@claudiorodriguez do you have an example for your solution? Running into this as well. |
@claudiorodriguez oh okay! I was looking through docs to see if I could find any |
I think it's undocumented. It's used here https://github.com/webpack-contrib/css-loader/blob/master/lib/getLocalIdent.js#L12 |
Damn, I looked at that file for like 10 minutes and I didn't spot that - @claudiorodriguez thank you! |
If you are use LoaderOptionsPlugin, then you can add context
classes will be unique |
@mitkaaa thanks, this works for me. but could you please explain why this would solve this issue? |
Agree @mitkaaa i'm a bit confused by the solution... is this global config or local to css loader? |
I think you can set @plrthink @dcworldwide I believe this works because css-loader uses the value of |
Won't |
Yeah, you're right. Seems to work anyway. ¯_(ツ)_/¯ Will try and dig into it further at some point. |
|
If you specify |
|
Ah, I see. My bad. |
@mitkaaa you saved me! |
Feel free to documentation this! |
Got same problem after moving to webpack-4.0.0beta. Updating css-loader with context fix this issue for me too. Config example:
Thanks so much for this solution! |
I've opened a PR to refer this problem and workaround in docs #770 |
Somebody can create minimum reproducible test repo? |
Closing due impossible reproduce. Feel free to create new issue if you faced with problem. Thanks! |
Hey everyone, just sharing a problem I found, to see if I'm missing something or if the suggested improvement could be a good idea.
If you go with the default options, or define your own
localIdentName
, the generatedhash
, without ahashPrefix
, will be a digest of the relative path and the local classname.This causes collision when you have two separate modules built with webpack that have a file with the same path, with the same classname in it (both modules have
src/blah/styles.scss
with the class.classname
in it)To solve this collision, I added a
hashPrefix
to thequery
, making it random on each build (something like<package-name> + Date.now()
works great).Isn't it a good idea to make a random
hashPrefix
be default behaviour?The text was updated successfully, but these errors were encountered: