Skip to content

Commit bf2e961

Browse files
WIP
1 parent c45616f commit bf2e961

File tree

14 files changed

+1028
-492
lines changed

14 files changed

+1028
-492
lines changed

packages/@tailwindcss-cli/src/commands/build/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ function optimizeCss(
446446
nonStandard: {
447447
deepSelectorCombinator: true,
448448
},
449-
include: Features.Nesting,
449+
include: Features.Nesting | Features.MediaQueries,
450450
exclude: Features.LogicalProperties | Features.DirSelector | Features.LightDark,
451451
targets: {
452452
safari: (16 << 16) | (4 << 8),

packages/@tailwindcss-postcss/src/__snapshots__/index.test.ts.snap

+8-4
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
164164
}
165165
166166
@supports (not ((-webkit-appearance: -apple-pay-button))) or (contain-intrinsic-size: 1px) {
167-
::placeholder {
168-
color: color-mix(in oklab, currentColor 50%, transparent);
167+
@supports (color: color-mix(in srgb, red 0%, red)) {
168+
::placeholder {
169+
color: color-mix(in oklab, currentColor 50%, transparent);
170+
}
169171
}
170172
}
171173
@@ -259,8 +261,10 @@ exports[`\`@import 'tailwindcss'\` is replaced with the generated CSS 1`] = `
259261
line-height: var(--tw-leading, var(--text-2xl--line-height));
260262
}
261263
262-
.text-black\\/50 {
263-
color: color-mix(in oklab, var(--color-black) 50%, transparent);
264+
@supports (color: color-mix(in srgb, red 0%, red)) {
265+
.text-black\\/50 {
266+
color: color-mix(in oklab, var(--color-black) 50%, transparent);
267+
}
264268
}
265269
266270
.underline {

packages/@tailwindcss-postcss/src/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ test('@apply can be used without emitting the theme in the CSS file', async () =
100100

101101
expect(result.css.trim()).toMatchInlineSnapshot(`
102102
".foo {
103-
color: var(--color-red-500, oklch(.637 .237 25.331));
103+
color: var(--color-red-500, oklch(63.7% .237 25.331));
104104
}"
105105
`)
106106
})

packages/@tailwindcss-postcss/src/index.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export type PluginOptions = {
5252
function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
5353
let base = opts.base ?? process.cwd()
5454
let optimize = opts.optimize ?? process.env.NODE_ENV === 'production'
55+
console.log({ opts, flag: process.env.NODE_ENV })
5556

5657
return {
5758
postcssPlugin: '@tailwindcss/postcss',
@@ -319,13 +320,13 @@ function optimizeCss(
319320
nonStandard: {
320321
deepSelectorCombinator: true,
321322
},
322-
include: LightningCssFeatures.Nesting,
323+
include: LightningCssFeatures.Nesting | LightningCssFeatures.MediaRangeSyntax,
323324
exclude:
324325
LightningCssFeatures.LogicalProperties |
325326
LightningCssFeatures.DirSelector |
326327
LightningCssFeatures.LightDark,
327328
targets: {
328-
safari: (16 << 16) | (4 << 8),
329+
safari: (15 << 16) | (4 << 8),
329330
ios_saf: (16 << 16) | (4 << 8),
330331
firefox: 128 << 16,
331332
chrome: 111 << 16,
@@ -334,9 +335,14 @@ function optimizeCss(
334335
}).code
335336
}
336337

338+
let out = optimize(optimize(Buffer.from(input))).toString()
339+
console.log({ out })
340+
341+
out = out.replaceAll(/\@media (\()?not /g, '@media $1not all and ')
342+
337343
// Running Lightning CSS twice to ensure that adjacent rules are merged after
338344
// nesting is applied. This creates a more optimized output.
339-
return optimize(optimize(Buffer.from(input))).toString()
345+
return out
340346
}
341347

342348
export default Object.assign(tailwindcss, { postcss: true }) as PluginCreator<PluginOptions>

packages/@tailwindcss-vite/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function optimizeCss(
143143
nonStandard: {
144144
deepSelectorCombinator: true,
145145
},
146-
include: LightningCssFeatures.Nesting,
146+
include: LightningCssFeatures.Nesting | LightningCssFeatures.MediaQueries,
147147
exclude:
148148
LightningCssFeatures.LogicalProperties |
149149
LightningCssFeatures.DirSelector |

packages/tailwindcss/src/__snapshots__/index.test.ts.snap

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`compiling CSS > \`@tailwind utilities\` is replaced by utilities using the default theme 1`] = `
44
":root, :host {
5-
--color-red-500: oklch(.637 .237 25.331);
5+
--color-red-500: oklch(63.7% .237 25.331);
66
--spacing: .25rem;
77
}
88
@@ -254,7 +254,13 @@ exports[`compiling CSS > prefix all CSS variables inside preflight 1`] = `
254254
255255
@supports (not ((-webkit-appearance: -apple-pay-button))) or (contain-intrinsic-size: 1px) {
256256
::placeholder {
257-
color: color-mix(in oklab, currentColor 50%, transparent);
257+
color: currentColor;
258+
}
259+
260+
@supports (color: color-mix(in srgb, red 50%, green)) {
261+
::placeholder {
262+
color: color-mix(in oklab, currentColor 50%, transparent);
263+
}
258264
}
259265
}
260266

0 commit comments

Comments
 (0)