Conversation
With `build.cssCodeSplit: false`, Vite emits the single stylesheet in its own generateBundle hook. The StyleX hook ran first because the plugin is `enforce: 'pre'`, found no CSS asset, and fell back to appending the rules in writeBundle, so the content hash in the filename never changed. Run generateBundle with `order: 'post'` so the stylesheet already exists and goes through the existing rehash path. Fixes facebook#1889
|
@kwy404 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed / motivation ?
With
build.cssCodeSplit: false, Vite emits the single stylesheet in its owngenerateBundlehook. Because the StyleX plugin isenforce: 'pre', itsgenerateBundleran first, found no CSS asset, and the rules were appended later inwriteBundle, so the content hash in the filename stayed the same after a StyleX-only edit. This runsgenerateBundlewithorder: 'post'so the stylesheet is already in the bundle and goes through the existingreplaceCssAssetWithHashedCopypath.Linked PR/Issues
Fixes #1889
Additional Context
Added a test that checks the hook order, and updated the two existing tests to call
generateBundle.handler. The unplugin Jest suite passes, and eslint and prettier are clean on the changed files.I also checked a local Vite 7 build with
cssCodeSplit: falsethat changespaddingTop: 16to32. Before, both builds emittedstyle-TZrNw7dA.css. After, they emitstyle-Brnp5ict.cssandstyle-XC-JYDyN.css, andindex.htmlpoints to the new file. WithcssCodeSplit: truethe output still changes its name as before.Pre-flight checklist
Contribution Guidelines