feat(css): add PostCSS support with css.transformer option#791
Merged
Conversation
Add PostCSS processing to the `@tsdown/css` CSS pipeline. PostCSS runs after preprocessors (Sass/Less/Stylus) and before Lightning CSS target lowering/minification, aligned with Vite's approach. - Add `css.postcss` option supporting inline config (object with plugins) or file-based config auto-detection via `postcss-load-config` - Add `postcss` as optional peer dependency of `@tsdown/css` - Add `postcss-load-config` as dependency for config file resolution - Cache file-based PostCSS config per search path - Track PostCSS plugin dependencies for watch mode
✅ Deploy Preview for tsdown-main ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
tsdown
create-tsdown
@tsdown/css
@tsdown/exe
tsdown-migrate
commit: |
…ning CSS paths
- Add `css.transformer` option ('postcss' | 'lightningcss') defaulting to 'postcss'
- PostCSS path: @import via postcss-import, PostCSS plugins, Lightning CSS for final transform
- Lightning CSS path: bundleAsync for @import, no PostCSS
- Add `css.postcss` option for inline PostCSS config or config file path
- Add postcss-import as optional peer dependency
- Update docs (EN/ZH) and skills reference with transformer/postcss documentation
- Add tests for lightningcss transformer path
css.transformer option
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.
Summary
Add PostCSS support to tsdown's CSS pipeline with a
css.transformeroption that controls mutually exclusive processing paths, aligned with Vite's design.Changes
css.transformeroption'postcss'(default):@importresolved bypostcss-import, PostCSS plugins applied, Lightning CSS used only for final syntax lowering/minification'lightningcss':@importresolved by Lightning CSSbundleAsync(), PostCSS not used at allcss.postcssoption{ plugins: [...] }) or config file path ('./config')postcss.config.jsfrom project root when omitted@tsdown/csspackage (from #790)@tsdown/csspackageFile Changes
src/features/css/index.ts: Addtransformer,postcsstoCssOptions/ResolvedCssOptionspackages/css/src/index.ts: Refactor intoloadWithLightningCSS/loadWithPostCSSpathspackages/css/src/postcss.ts: PostCSS processing with autopostcss-importinjectionsrc/features/css/post.ts: Extract shared CSS post-processing hookssrc/features/css/pure-chunk.ts: Pure CSS chunk handlingsrc/css.ts: Newtsdown/cssexport for shared typesdocs/options/css.md,docs/zh-CN/options/css.md: Document transformer, PostCSS optionstests/css.test.ts: 18 tests covering both transformer pathsType of Change
Testing
@importinlining, PostCSS plugins (inline + config file), PostCSS with@import, Lightning CSS transformer path, Lightning CSS ignoring PostCSS plugins🤖 Generated with Claude Code