Skip to content
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

fix(css-plugin): Use generateBundle hook to prevent CSS imports from being lost #112

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Jan 27, 2024

We must use generateBundle as Vite removes "empty css chunks" (chunks that only import css) in its generateBundle hook and merged the importedCss property down to the really emitted chunks.
Otherwise we will loose CSS imports!

See this example of the NcMentionBubble on the comments tab, current master with 8.5.1 the "after" with 8.5.1 but compiled with this changes.

before after
Screenshot_20240127_004747 Screenshot_20240127_004946

@susnux susnux added bug Something isn't working 3. to review Ready to review labels Jan 27, 2024
Copy link

codecov bot commented Jan 27, 2024

Codecov Report

Attention: 25 lines in your changes are missing coverage. Please review.

Comparison is base (38a8ed6) 81.09% compared to head (d7d3647) 80.06%.
Report is 6 commits behind head on main.

❗ Current head d7d3647 differs from pull request most recent head 0a801cc. Consider uploading reports for the commit 0a801cc to get more accurate results

Files Patch % Lines
lib/plugins/ImportCSS.ts 30.55% 25 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
- Coverage   81.09%   80.06%   -1.04%     
==========================================
  Files           8        8              
  Lines         582      602      +20     
  Branches       48       48              
==========================================
+ Hits          472      482      +10     
- Misses         62       72      +10     
  Partials       48       48              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@Antreesy Antreesy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got the general reference for skipped css chunks at generateBundle
Please correct me, if I'm wrong with a source: https://github.com/vitejs/vite/blob/3fceb14b94b12d12d47285402980f360aa4284ea/packages/vite/src/node/plugins/css.ts#L861-L863

Also tested with apps, config does its job 🎉

Copy link
Contributor

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐘

@susnux susnux merged commit 85a5da0 into main Jan 29, 2024
12 checks passed
@susnux susnux deleted the fix/css-import-plugin branch January 29, 2024 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Ready to review bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NcRichContenteditable: @mention item is not rendered properly in other apps
3 participants