-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
The hash of css class names packaged on different platform systems is inconsistent #5136
Comments
Looks like the Astro compiler builds the hash based on the content and file name since withastro/compiler#513. Maybe we should use a project-root-relative path to compute the hash? cc @matthewp |
import path from 'node:path';
import slash from 'slash';
// project root
const root = __dirname
// current filepath
const src = ''
const slashSrc = slash(path.normalize(path.relative(root, src)));
const hash = createHash(slashSrc)
// const hash = createHash(slashSrc + `${code}`) |
Yes we should! I plan on fixing this. @J-env this happens inside of our (Go-based) compiler. But I think we have all of the information to make this root-relative. |
Looking into it, we don't actually pass in the moduleId so it is just based on the source. I wonder if the source is what is different between platforms, probably because of the different line endings? |
In my case this issue seems to be causing certain CSS modules rules works in dev but missing in prod.
I'll try roll back few Astro versions to see when it starts breaking. Update: I can confirm that for my case, Update 2: I tried to create a minimal reproduction but not able to. Wish I can be more helpful :( |
I think this is already fixed but forgot to closed. We are now deriving a root-relative normalized path to generate the hash, so something like @malcolm-kee if you can reproduce this, feel free to open a new issue. Thanks! |
What version of
astro
are you using?1.5.2
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
The hash of the css class name is inconsistent, resulting in a change in the hash of the packaged file.
Mac output file: [name].f6446fc8.css
Windows output: [name].12333479.css
Link to Minimal Reproducible Example
none
Participation
The text was updated successfully, but these errors were encountered: