feat(css): build assets with the entry name when it is an entry point#11578
feat(css): build assets with the entry name when it is an entry point#11578sapphi-red merged 4 commits intovitejs:mainfrom
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.
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 |
| 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.
Do you have a reason to remove this test? I think we shouldn't remove this one.
There was a problem hiding this comment.
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.
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.
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.
@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.cssandX.csswhen specifying an entry like this:Inside the
assetFileNameshook, 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).