-
Hello! Is there a way to remove unused css variables from the output? The docs recommend using purgecss, but I've had little luck getting it to output anything useful. For context: I'm not using any of the colors that come bundled with panda, yet they're all still there in the output. Keyframes too, as well as sizing/spacing tokens I'm not using anywhere. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
you can use hooks for this import { defineConfig } from '@pandacss/dev'
import { removeUnusedCssVars } from './remove-unused-css-vars'
import { removeUnusedKeyframes } from './remove-unused-keyframes'
export default defineConfig({
// ...
hooks: {
'cssgen:done': ({ artifact, content }) => {
if (artifact === 'styles.css') {
return removeUnusedCssVars(removeUnusedKeyframes(content))
}
},
}
} https://github.com/chakra-ui/panda/blob/6b829cab35767e2d2552e105344c8b01e0ee13ce/sandbox/vite-ts/remove-unused-css-vars.ts note that using this means you can't use the JS function |
Beta Was this translation helpful? Give feedback.
you can use hooks for this
https://github.com/chakra-ui/panda/blob/6b829cab35767e2d2552e105344c8b01e0ee13ce/sandbox/vite-ts/remove-unused-css-vars.ts
https://github.com/chakra-ui/panda/blob/6b829cab35767e2d2552e105344c8b01e0ee13ce/sandbox/vite-ts/remove-unused-keyframes.ts
note that using this me…