Skip to content

feat: add CSS code splitting support#654

Merged
sxzz merged 15 commits intorolldown:mainfrom
jinghaihan:feat/css-code-split
Dec 26, 2025
Merged

feat: add CSS code splitting support#654
sxzz merged 15 commits intorolldown:mainfrom
jinghaihan:feat/css-code-split

Conversation

@jinghaihan
Copy link
Copy Markdown
Contributor

@jinghaihan jinghaihan commented Dec 17, 2025

Description

This PR adds CSS code splitting support to tsdown, allowing users to merge all CSS files into a single style.css file when cssCodeSplit: false is enabled.

Motivation:

Bundlers typically don't automatically import CSS files, which creates complexity for library developers using Vue SFCs when building async components. After reviewing Vite's implementation, I ported their cssCodeSplit option to tsdown to simplify CSS handling for library consumers.

Implementation:

  • Added cssCodeSplit configuration option (defaults to true to preserve existing behavior)
  • CSS is merged in the order: synchronous imports first (lowest priority), then dynamic imports (highest priority)
  • Individual CSS files are removed from the bundle after merging

Additional context

Testing scope:
I primarily work with Vue development, so this feature has been tested in Vue projects.

Default value consideration:
Given that tsdown is primarily used as a library bundler, there might be a case for making cssCodeSplit: false the default value, as it simplifies CSS handling for library consumers.

Credits:
This implementation is based on Vite's CSS code splitting feature.

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 17, 2025

Deploy Preview for tsdown ready!

Name Link
🔨 Latest commit 34ffe7a
🔍 Latest deploy log https://app.netlify.com/projects/tsdown/deploys/694e32f231c1bf000811ab36
😎 Deploy Preview https://deploy-preview-654--tsdown.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Dec 17, 2025

Open in StackBlitz

npm i https://pkg.pr.new/tsdown@654
npm i https://pkg.pr.new/create-tsdown@654
npm i https://pkg.pr.new/tsdown-migrate@654

commit: 34ffe7a

@jinghaihan jinghaihan marked this pull request as draft December 20, 2025 15:06
@jinghaihan jinghaihan marked this pull request as ready for review December 20, 2025 15:08
@sxzz sxzz merged commit 0525f30 into rolldown:main Dec 26, 2025
12 checks passed
@jinghaihan jinghaihan deleted the feat/css-code-split branch December 26, 2025 07:03
@EDM115
Copy link
Copy Markdown

EDM115 commented Dec 30, 2025

that's so cool !

jinghaihan added a commit to jinghaihan/vue-stream-markdown that referenced this pull request Jan 4, 2026
jinghaihan added a commit to jinghaihan/vue-stream-markdown that referenced this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants