Skip to content

Remove unused variables from output #2155

Answered by astahmer
iscekic asked this question in Q&A
Discussion options

You must be logged in to vote

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
https://github.com/chakra-ui/panda/blob/6b829cab35767e2d2552e105344c8b01e0ee13ce/sandbox/vite-ts/remove-unused-keyframes.ts

note that using this me…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@iscekic
Comment options

@astahmer
Comment options

@iscekic
Comment options

@anubra266
Comment options

Answer selected by iscekic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants