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

[bug]: npx shadcn init doesn't work when variables are in tailwind.config.js #4993

Open
2 tasks done
nicksmithr opened this issue Sep 27, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@nicksmithr
Copy link

Describe the bug

When running npx shadcn@latest in a project which has variables within the tailwind.config.js theme.extend, it fails to run with:

Error replacing tree: The children of the old and new trees were expected to have the same count (8:21).

There's an issue with ts-morph.

E.g. with:

const defaultTheme = require('tailwindcss/defaultTheme');

export default {
    content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
    theme: {
        extend: {
            fontFamily: {
                sans: ['Plus Jakarta Sans Variable', ...defaultTheme.fontFamily.sans],
                mono: ['Silkscreen', ...defaultTheme.fontFamily.sans]
            },
    plugins: [require('tailwindcss-motion')]
};

The ...defaultTheme is causing it to fail. I imagine the parser isn't accounting for variables inside the config, but I think it's quite a common setup

Affected component/components

N/A

How to reproduce

  1. Use above config
  2. Run npx shadcn init

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

MacOS / Warp terminal / Cursor

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@nicksmithr nicksmithr added the bug Something isn't working label Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant