You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently upgraded to create-react-app 2.1.8 and noticed the hashes used in css modules classnames are different in different build environments. I did some debugging and saw that 'react-dev-utils/getCSSModuleLocalIdent' uses 'context.resourcePath + localName' for the hash generation and that context.resourcePath was an absolute path. The original discussion (#3965) indicated we wanted the full path for uniqueness and that we also wanted to preserve keep the classnames deterministic for automated testing. It seems like trimming the context.resourcePath of context.rootContext would preserve uniqueness within the project and allow users to write tests against the classnames locally and have it work on different machines regardless of the project path.
Example of the issue, the classnames for css modules in the below two repo locations will hash to different values in the current code:
/Users/person1/projectrepo/
/Users/person2/projectrepo/
If in getCSSModuleLocalIdent we change the code to something like the below, the hashes will be the same
I recently upgraded to create-react-app 2.1.8 and noticed the hashes used in css modules classnames are different in different build environments. I did some debugging and saw that 'react-dev-utils/getCSSModuleLocalIdent' uses 'context.resourcePath + localName' for the hash generation and that context.resourcePath was an absolute path. The original discussion (#3965) indicated we wanted the full path for uniqueness and that we also wanted to preserve keep the classnames deterministic for automated testing. It seems like trimming the context.resourcePath of context.rootContext would preserve uniqueness within the project and allow users to write tests against the classnames locally and have it work on different machines regardless of the project path.
Example of the issue, the classnames for css modules in the below two repo locations will hash to different values in the current code:
/Users/person1/projectrepo/
/Users/person2/projectrepo/
If in getCSSModuleLocalIdent we change the code to something like the below, the hashes will be the same
I'd be happy to submit a PR if this makes sense and I didn't miss something obvious. Thank you!
The text was updated successfully, but these errors were encountered: