Skip to content

Commit 2b66c57

Browse files
committed
Tweak CSS printing
How this prints will be dependent on Tailwind CSS version. Since we don’t know what version that is yet we’ll set up a simple toggle that we can flip after (eventually) threading version information through.
1 parent becb150 commit 2b66c57

File tree

1 file changed

+6
-1
lines changed
  • packages/tailwindcss-language-service/src/css

1 file changed

+6
-1
lines changed

packages/tailwindcss-language-service/src/css/to-css.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Source } from './source'
33

44
export function toCss(ast: AstNode[], track?: boolean): string {
55
let pos = 0
6+
let supportsBodylessAtRules = false
67

78
let source: Source = {
89
file: null,
@@ -84,14 +85,18 @@ export function toCss(ast: AstNode[], track?: boolean): string {
8485

8586
// AtRule
8687
else if (node.kind === 'at-rule') {
88+
let isBodyless = supportsBodylessAtRules
89+
? !node.nodes
90+
: !node.nodes || node.nodes.length === 0
91+
8792
// Print at-rules without nodes with a `;` instead of an empty block.
8893
//
8994
// E.g.:
9095
//
9196
// ```css
9297
// @layer base, components, utilities;
9398
// ```
94-
if (!node.nodes) {
99+
if (isBodyless) {
95100
let css = `${indent}${node.name} ${node.params};\n`
96101

97102
if (track) {

0 commit comments

Comments
 (0)