feat(css): support ?inline query for CSS imports#810
Merged
Conversation
Aligns with Vite's `?inline` behavior: `import css from './foo.css?inline'` returns the fully processed CSS as a JS string export instead of emitting a separate CSS file. - Add `resolveId`/`load` hooks scoped to CSS `?inline` (won't intercept non-CSS `?inline` like `foo.svg?inline`) - Process inline CSS through the full pipeline (preprocessors, Lightning CSS, PostCSS, @import bundling, minification) - Return `export default "..."` with `moduleSideEffects: false` (tree-shakeable) - Fix `getPreprocessorLang` to use clean ID (without query) so SCSS/Less/Stylus compile correctly with `?inline` - Allow `?inline` CSS through `@import` bundling path (real files, not virtual) - Move `CSS_LANGS_RE` to shared utils
✅ 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: |
`RE_CSS_INLINE` now matches `foo.css?x=1&inline` in addition to `foo.css?inline`, aligning with Vite's `[?&]inline` pattern.
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
Adds Vite-aligned
?inlinesupport for CSS imports.import css from './foo.css?inline'returns the fully processed CSS as a JS string export instead of emitting a separate.cssfile.resolveId/loadhooks scoped to CSS?inline(won't intercept non-CSS?inlinelikefoo.svg?inline)export default "..."withmoduleSideEffects: false(tree-shakeable)getPreprocessorLangto use clean ID (without query) so SCSS/Less/Stylus compile correctly with?inline?inlineCSS through@importbundling path (real files, not virtual)CSS_LANGS_REto shared utilsTest plan
.css?inline— CSS inlined as JS string, no.cssfile emitted.scss?inline— verifies SCSS is actually compiled ($colorvariable resolved)?inlinecoexist (regular →.cssfile, inline → JS string).css?rawwithunplugin-rawstill works#800) still works