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

get error "Could not parse CSS stylesheet" when CSS file contains nested rules #5738

Closed
6 tasks done
mvolkmann opened this issue May 16, 2024 · 2 comments
Closed
6 tasks done

Comments

@mvolkmann
Copy link

Describe the bug

When testing a component that imports a CSS file that contains nested CSS rules, I get the error "Could not parse CSS stylesheet". Support for nested CSS rules is fairly new, so maybe the parser that vitest uses to parse CSS just doesn't support nested rules yet.

Reproduction

Here is a simple example of CSS that will trigger this error:

.foo {
  .bar {
    color: red;
  }
}

System Info

System:
    OS: macOS 14.2
    CPU: (10) x64 Apple M1 Pro
    Memory: 47.48 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.1 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 10.2.4 - /usr/local/bin/npm
    pnpm: 7.30.1 - /opt/homebrew/bin/pnpm
    bun: 1.1.6 - ~/.bun/bin/bun
    Watchman: 2024.01.22.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 124.0.6367.208
    Edge: 118.0.2088.46
    Safari: 17.2
    Safari Technology Preview: 17.4
  npmPackages:
    @vitejs/plugin-react-swc: ^3.6.0 => 3.6.0
    @vitest/coverage-v8: ^1.4.0 => 1.5.1
    vite: ^5.2.6 => 5.2.10
    vitest: ^1.4.0 => 1.5.1

Used Package Manager

yarn

Validations

@hi-ogawa
Copy link
Contributor

Not sure if I missed something, but I couldn't reproduce https://stackblitz.com/edit/vitest-dev-vitest-mdakvj?file=test%2Frepro.css

Can you provide a runnable example?

Copy link

Hello @mvolkmann. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants