You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/options/css.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,26 @@ CSS `@import` statements are automatically resolved and inlined into the output.
46
46
47
47
All imported CSS is bundled into a single output file with `@import` statements removed.
48
48
49
+
### Inline CSS (`?inline`)
50
+
51
+
Appending `?inline` to a CSS import returns the fully processed CSS as a JavaScript string instead of emitting a separate `.css` file. This aligns with [Vite's `?inline` behavior](https://vite.dev/guide/features#disabling-css-injection-into-the-page):
52
+
53
+
```ts
54
+
importcssfrom'./theme.css?inline'// Returns processed CSS as a string
55
+
import'./style.css'// Extracted to a .css file
56
+
console.log(css) // ".theme { color: red; }\n"
57
+
```
58
+
59
+
The `?inline` CSS goes through the full processing pipeline — preprocessors, `@import` inlining, syntax lowering, and minification — just like regular CSS. The only difference is the output format: a JavaScript string export instead of a CSS asset file.
60
+
61
+
This also works with preprocessors:
62
+
63
+
```ts
64
+
importcssfrom'./theme.scss?inline'
65
+
```
66
+
67
+
When `?inline` is used, the CSS is not included in the emitted `.css` files and the import is tree-shakeable (`moduleSideEffects: false`).
68
+
49
69
## CSS Pre-processors
50
70
51
71
`tsdown` provides built-in support for `.scss`, `.sass`, `.less`, `.styl`, and `.stylus` files. The corresponding pre-processor must be installed as a dev dependency:
CSS `@import` statements are resolved and inlined automatically. No separate output files produced.
32
32
33
+
### Inline CSS (`?inline`)
34
+
35
+
Append `?inline` to return processed CSS as a JS string instead of emitting a `.css` file:
36
+
37
+
```ts
38
+
import'./style.css'// → .css file
39
+
importcssfrom'./theme.css?inline'// → JS string
40
+
```
41
+
42
+
Works with preprocessors too (`./foo.scss?inline`). Goes through full pipeline (preprocessors, @import inlining, lowering, minification). Tree-shakeable (`moduleSideEffects:false`).
43
+
33
44
## CSS Pre-processors
34
45
35
46
Built-in support for Sass, Less, and Stylus. Install the preprocessor:
0 commit comments