Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVA and SVA not pre-generating CSS #2307

Closed
1 of 3 tasks
waraness99 opened this issue Mar 5, 2024 · 1 comment
Closed
1 of 3 tasks

CVA and SVA not pre-generating CSS #2307

waraness99 opened this issue Mar 5, 2024 · 1 comment

Comments

@waraness99
Copy link

waraness99 commented Mar 5, 2024

Description

When I use CVA or SVA in my NX project, CSS is not generated. However, it works fine with props.

export const Route = createFileRoute('/')({
  component: () => {
    const square2 = cva({
      base: {
        w: '16',
        h: '16',
        bg: 'green.600',
      },
    });

    return (
      <Stack gap="4" m="16">
        <Box w="16" h="16" bg="red.600" />
        {/* 👇 CVA, SVA will not be pre-generated */}
        <Box className={square2()} />
        <Box css={{w:"16", h:"16", bg:"blue.600"}} />
      </Stack>
    );
  },
});
image

Link to Reproduction

https://stackblitz.com/~/github.com/waraness99/panda-test

Steps to reproduce

My panda config with NX is not great yet...

  1. Run npm i.
  2. Go tolibs/styled-system/panda.config.ts and temporary edit outdir to ./src/lib/__generated__.
  3. Run: cd libs/styled-system && npx panda.
  4. Revert outdir path to its initial value (./libs/styled-system/src/lib/__generated__).
  5. Open a new terminal and run npx nx serve desktop-front.
  6. See error where the 2nd square has no styles.

JS Framework

React (TS)

Panda CSS Version

0.33.0

Browser

Chromium Engine Version 121.0.6167.184

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

No response

@astahmer
Copy link
Collaborator

astahmer commented Mar 5, 2024

please check this repo and follow the same structure as in the examples
https://github.com/astahmer/panda-monorepo-setup


I don't recommend using an importMap that contains every entrypoints (css recipes patterns etc), and I dont' recommend having a lib/styled-system taking care of the CSS generated for the app either, but still, if you really want this you can make it work like this:

import { defineConfig } from '@pandacss/dev';
import path from "node:path"

const monorepoRoot = path.resolve(__dirname, "../..")

export default defineConfig({
  preflight: true,
  jsxFramework: 'react',
  include: [path.join(monorepoRoot, './apps/**/*.{ts,tsx}'), './libs/**/*.{ts,tsx}'],
  outdir: './src/lib/__generated__',
  exclude: [],
  importMap: {
    css: '@panda-test/styled-system',
    recipes: '@panda-test/styled-system',
    patterns: '@panda-test/styled-system',
    jsx: '@panda-test/styled-system',
 }
});

@astahmer astahmer closed this as completed Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants