-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
feat(css): build assets with the entry name when it is an entry point #11578
Conversation
2b21f7d
to
79777fc
Compare
We need this feature as we have multiple pages that act as independent apps. Perhaps @patak-dev could have a review/merge this please? |
const lang = path.extname(cssAssetName).slice(1) | ||
const cssFileName = ensureFileExt(cssAssetName, '.css') | ||
const cssFileName = ensureFileExt( | ||
isEntry ? chunk.name : cssAssetName, |
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 think we should have this condition directly in line 552.
This looks good to me, but modifying the naming could be a breaking change. I added it to the Vite 5 milestone (to be released in September). @Maxim-Mazurok, in the meantime, I recommend you maintain a patch for Vite in your repo so you aren't blocked by Vite's release process. |
Thank you, we've decided to have two separate vite configs for now that extend a common one, seems to work fine for us for now |
@@ -37,7 +37,6 @@ describe.runIf(isBuild)('build', () => { | |||
const cssAssetEntry = manifest['global.css'] | |||
const scssAssetEntry = manifest['nested/blue.scss'] | |||
const imgAssetEntry = manifest['../images/logo.png'] | |||
const dirFooAssetEntry = manifest['../../dir/foo.css'] // '\\' should not be used even on windows |
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.
Do you have a reason to remove this test? I think we shouldn't remove this one.
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.
Because the behaviour has broken and used the chunk name as the name of the assets, so should test manifest['bar.css']
and manifest['foo.css']
. The case has not actually been removed.
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.
Isn't that because you changed this line?
https://github.com/vitejs/vite/pull/11578/files#diff-4fdf9a690fa55c7c730e03a900f729ce1afb886d64b4280cd4ce0f32d5844074L22-R22
I guess it would work if you revert that change.
I think you can append another entry point for the new test.
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.
Even if I revert the change, the chunk name has been used as the CSS asset name, instead of the path before, because this is an entry.
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.
@sapphi-red Due to these changes, the asset name has used chunk.name
instead of the path, which has broken the test case.
I restored the test for #9353 by adding a dynamic import chunk. Also I found that the Windows test was failing and fixed that as well. |
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
histoire: faling with using yarn in |
@patak-dev @sapphi-red @aleen42 This actually led to bad entry being added into Should I open new issue to this? I've noticed this is happening when I was testing v5 beta. |
@lubomirblazekcz could you create an issue with a minimal reproduction so we can better evaluate if this is expected or not? |
@patak-dev sure, here - #14943 |
REF: #4863 (comment)
How can we use the entry name to construct two files with the name
L.css
andX.css
when specifying an entry like this:Inside the
assetFileNames
hook, we cannot distinguish two assets with the same nameindex.css
.In comparison with Webpack, it will use the entry name as the asset name when using the plugin,
mini-css-extract-plugin
.Description
To resolve the problem mentioned above, I hope that Vite can use the entry name as the asset name.
fix #9877
close #9485
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).