Generate CSS file with all variants #854
-
Is it possible to generate CSS file with all variants including the unused ones? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
hey, yes you can "static" CSS (as in, always generating it even if no usage found in your app) using |
Beta Was this translation helpful? Give feedback.
-
Hello, thanks for your reply. Unfortunately, I cannot configure this so that variants are generated. // panda.config.ts
import { defineConfig } from '@pandacss/dev';
export default defineConfig({
include: ['./src/*.{tsx,jsx}'],
jsxFramework: 'react',
staticCss: {
recipes: {
button: ['*'],
},
},
theme: {
extend: {
recipes: {
button: {
name: 'button',
base: {},
variants: {
size: {
small: { padding: '6px 12px', height: '32px' },
medium: { padding: '8px 16px', height: '40px' },
large: { padding: '12px 24px', height: '48px' },
},
},
},
},
},
},
}); My Button component // src/Button.tsx
import { button } from '../styled-system/recipes';
type ButtonProps = { size: 'small' | 'medium' | 'large' };
export const Button = ({ size = 'medium' }: ButtonProps) => {
return <button className={button({ size })}>Button</button>;
}; When I run @layer reset, base, tokens, recipes, utilities;
@import './global.css';
@import './static.css';
@import './tokens/index.css';
@import './tokens/keyframes.css'; When I add a component that uses the variant // src/SmallButton.tsx
import { Button } from './Button';
export const SmallButton = () => {
return <Button size="small" />;
}; and run @layer reset, base, tokens, recipes, utilities;
@import './global.css';
@import './static.css';
@import './tokens/index.css';
@import './tokens/keyframes.css';
@layer recipes {
.button--size_small {
padding: 6px 12px;
height: 32px
}
} I need to generate style.css with all recipe variant classes and styles without using variant values explicitly in the code. |
Beta Was this translation helpful? Give feedback.
-
Ah, and static.css file was not created and an error with message "Error: Can't resolve './static.css'" occurs. |
Beta Was this translation helpful? Give feedback.
-
doing this
I couldnt reproduce this, if the issue still happens, can you make a minimal repro from this template ? |
Beta Was this translation helpful? Give feedback.
-
Thank you, |
Beta Was this translation helpful? Give feedback.
hey, yes you can "static" CSS (as in, always generating it even if no usage found in your app) using
config.staticCss