Skip to content

Commit cc8ee04

Browse files
authored
Merge branch 'main' into feat/bump-prettier
2 parents e8045e3 + 5a94f81 commit cc8ee04

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Do not generate `grid-row` utilities when configuring `grid-row-start` or `grid-row-end` ([#18907](https://github.com/tailwindlabs/tailwindcss/pull/18907))
2222
- Prevent duplicate CSS when overwriting a static utility with a theme key ([#18056](https://github.com/tailwindlabs/tailwindcss/pull/18056))
2323
- Do not migrate `variant = 'outline'` during upgrades ([#18922](https://github.com/tailwindlabs/tailwindcss/pull/18922))
24+
- Show Lightning CSS warnings (if any) when optimizing/minifying ([#18918](https://github.com/tailwindlabs/tailwindcss/pull/18918))
25+
- Use `default` export condition for `@tailwindcss/vite` ([#18948](https://github.com/tailwindlabs/tailwindcss/pull/18948))
2426

2527
## [4.1.13] - 2025-09-03
2628

packages/@tailwindcss-node/src/optimize.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,48 @@ export function optimize(
6060
let result = optimize(Buffer.from(input), map)
6161
map = result.map?.toString()
6262

63+
// Because of `errorRecovery: true`, there could be warnings, so let's let the
64+
// user know about them.
65+
if (process.env.NODE_ENV !== 'test' && result.warnings.length > 0) {
66+
let lines = input.split('\n')
67+
68+
let output = [
69+
`Found ${result.warnings.length} ${result.warnings.length === 1 ? 'warning' : 'warnings'} while optimizing generated CSS:`,
70+
]
71+
72+
for (let [idx, warning] of result.warnings.entries()) {
73+
output.push('')
74+
if (result.warnings.length > 1) {
75+
output.push(`Issue #${idx + 1}:`)
76+
}
77+
78+
let context = 2
79+
80+
let start = Math.max(0, warning.loc.line - context - 1)
81+
let end = Math.min(lines.length, warning.loc.line + context)
82+
83+
let snippet = lines.slice(start, end).map((line, idx) => {
84+
if (start + idx + 1 === warning.loc.line) {
85+
return `${dim(`\u2502`)} ${line}`
86+
} else {
87+
return dim(`\u2502 ${line}`)
88+
}
89+
})
90+
91+
snippet.splice(
92+
warning.loc.line - start,
93+
0,
94+
`${dim('\u2506')}${' '.repeat(warning.loc.column - 1)} ${yellow(`${dim('^--')} ${warning.message}`)}`,
95+
`${dim('\u2506')}`,
96+
)
97+
98+
output.push(...snippet)
99+
}
100+
output.push('')
101+
102+
console.warn(output.join('\n'))
103+
}
104+
63105
result = optimize(result.code, map)
64106
map = result.map?.toString()
65107

@@ -88,3 +130,11 @@ export function optimize(
88130
map,
89131
}
90132
}
133+
134+
function dim(str: string) {
135+
return `\x1B[2m${str}\x1B[22m`
136+
}
137+
138+
function yellow(str: string) {
139+
return `\x1B[33m${str}\x1B[39m`
140+
}

packages/@tailwindcss-node/tsup.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,35 @@ export default defineConfig([
66
minify: true,
77
dts: true,
88
entry: ['src/index.cts'],
9+
define: {
10+
'process.env.NODE_ENV': '"production"',
11+
},
912
},
1013
{
1114
format: ['esm'],
1215
minify: true,
1316
dts: true,
1417
entry: ['src/index.ts'],
18+
define: {
19+
'process.env.NODE_ENV': '"production"',
20+
},
1521
},
1622
{
1723
format: ['esm'],
1824
minify: true,
1925
dts: true,
2026
entry: ['src/esm-cache.loader.mts'],
27+
define: {
28+
'process.env.NODE_ENV': '"production"',
29+
},
2130
},
2231
{
2332
format: ['cjs'],
2433
minify: true,
2534
dts: true,
2635
entry: ['src/require-cache.cts'],
36+
define: {
37+
'process.env.NODE_ENV': '"production"',
38+
},
2739
},
2840
])

packages/@tailwindcss-vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"exports": {
2525
".": {
2626
"types": "./dist/index.d.mts",
27-
"import": "./dist/index.mjs"
27+
"default": "./dist/index.mjs"
2828
}
2929
},
3030
"dependencies": {

0 commit comments

Comments
 (0)