-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Description
Steps to reproduce
- Create a fresh Vite project.
- Add Tailwind following the Installation guide.
- Add
@import "tailwindcss";. - Do not use any Tailwind classes in the code.
- Run the
npm run buildcommand.
Expected result
The generated CSS file should contain only essential styles, such as CSS resets, with a file size of approximately 2 KB.
Actual result
The generated CSS file includes a significant number of unused styles, with a total size of 21.8 KB.
- ~360 CSS variables,
utilitiesstyles,@keyframesrules,@propertyrules.
Workaround
PurgeCSS can remove most of the unused styles, except for @property rules:
// postcss.config.js
import { purgeCSSPlugin } from '@fullhuman/postcss-purgecss';
export default {
plugins: [
purgeCSSPlugin( {
content: [
'./index.html',
'./src/**/*'
],
fontFace: true,
keyframes: true,
variables: true
} )
]
}With this configuration, the final CSS file size is reduced to approximately 4 KB.
paulmelero and joaopedrodcfmathieutu
Metadata
Metadata
Assignees
Labels
No labels