mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
This PR improves the DX by showing all the Lightning CSS warnings when using a "production" build (or using `--optimize` or `--minify` flags when using the CLI). Right now Tailwind CSS itself doesn't care about the exact syntax you are using in the CSS as long as it looks valid. We do this because otherwise we would have to parse a lot more CSS syntax and validate it even though it would be valid CSS in 99.99% of the cases. Even worse, if you want to use newer CSS syntax that Tailwind CSS doesn't validate yet, then you would get warnings for valid CSS. Another reason why we don't do this is because the browser already does a great job at ignoring invalid CSS. So the linked issue #15872 would still silently fail in development mode. In this case, everything would work, except the shadow with the invalid syntax. But in production mode, you would now get a proper warning from Lightning CSS, because they try to optimize the CSS and remove invalid CSS. One potential issue here is that we run Lightning CSS on the generated CSS, not on the input CSS. So the current output shows the warnings in the output CSS not the input CSS. Any thoughts if we would just skip the line numbers? ## Test plan 1. Everything works as before 2. In production mode, you would get warnings printed to the terminal. This is done in `@tailwindcss/node` so the CLI/Vite/PostCSS plugins would all get the same behavior. Screenshots: If you have a single issue: <img width="977" height="441" alt="image" src="https://github.com/user-attachments/assets/7b061ee9-b74f-4b40-aa05-cff67a21dfcc" /> If you have multiple issues: <img width="2170" height="711" alt="image" src="https://github.com/user-attachments/assets/a5bc9b0a-964b-465f-80f3-d30dd467e69c" /> Fixes: #15872
41 lines
728 B
TypeScript
41 lines
728 B
TypeScript
import { defineConfig } from 'tsup'
|
|
|
|
export default defineConfig([
|
|
{
|
|
format: ['cjs'],
|
|
minify: true,
|
|
dts: true,
|
|
entry: ['src/index.cts'],
|
|
define: {
|
|
'process.env.NODE_ENV': '"production"',
|
|
},
|
|
},
|
|
{
|
|
format: ['esm'],
|
|
minify: true,
|
|
dts: true,
|
|
entry: ['src/index.ts'],
|
|
define: {
|
|
'process.env.NODE_ENV': '"production"',
|
|
},
|
|
},
|
|
{
|
|
format: ['esm'],
|
|
minify: true,
|
|
dts: true,
|
|
entry: ['src/esm-cache.loader.mts'],
|
|
define: {
|
|
'process.env.NODE_ENV': '"production"',
|
|
},
|
|
},
|
|
{
|
|
format: ['cjs'],
|
|
minify: true,
|
|
dts: true,
|
|
entry: ['src/require-cache.cts'],
|
|
define: {
|
|
'process.env.NODE_ENV': '"production"',
|
|
},
|
|
},
|
|
])
|