-
-
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
Make CSS chunk names less confusing #8754
Conversation
🦋 Changeset detectedLatest commit: ee00eec The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
43ccc05
to
7f17321
Compare
|
||
import crypto from 'node:crypto'; | ||
import npath from 'node:path'; | ||
import type { AstroSettings } from '../../@types/astro.js'; | ||
import { viteID } from '../util.js'; | ||
import { getTopLevelPages } from './graph.js'; | ||
|
||
// These pages could be used as base names for the chunk hashed name, but they are confusing | ||
// and should be avoided it possible | ||
const confusingBaseNames = ['404', '500']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to avoid dynamic routes as well, for instance, my website's CSS file is named _...page_.1d4448e7.css
(with the underscore at the start, weirdly enough)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could perhaps look into prettify some names too 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it so .
is converted to _
, and multiple _
are collapsed to a single _
. So _...page_.1d4448e7.css
should look like _page_.1d4448e7.css
now. There could be same names if there's [slug]
and [...slug]
side-by-side, but I think it should be fine (hashes are still different so chunking is still correct).
Do we need to include a real file's name at all? Could we let it be just the hash? |
I think we still need some sort of memorable name so it's easier to debug things when needed. |
Changes
fix #7469
This PR implements a lame algorithm to pick a chunk base name that is not confusing. Simply by avoiding the
404
and500
names if there's others available.I couldn't quite figure out a better naming-scheme without overcomplicating it. I also tried resorting this to Rollup, but there's edgecases where that's not possible. Our CSS handling that links CSS to HTML pages are very ingrained throughout the codebase. Also in practice, Rollup would also pick the confusing name otherwise.
Testing
Tested manually.
Docs
n/a.