"Can't find stylesheet to import" when using --threads=false

See original GitHub issue

Describe the bug

“vitest run” works fine, tests pass “vitest run --threads=false” errors out with “can’t find stylesheet to import”

in my repro, styles.scss is imported into App.tsx, and it in turn imports a stylesheet called “colors.scss”

I was only using threads=false to try to get around a Node issue in my CI build, but it doesn’t work.

Reproduction

https://github.com/oneillsp96/vitest-error-2

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 16.54 GB / 31.83 GB
  Binaries:
    Node: 16.14.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 8.5.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 100.0.4896.127
    Edge: Spartan (44.19041.1266.0), Chromium (101.0.1210.32)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @vitejs/plugin-react: ^1.3.0 => 1.3.1
    vite: ^2.9.5 => 2.9.5
    vitest: ^0.9.3 => 0.9.3

Used Package Manager

yarn

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:4
  • Comments:11

github_iconTop GitHub Comments

2reactions
nathanchickencommented, May 19, 2022

The only real place I get this being an issue is in the preprocessorOptions part.

So to circumvent the issue for now I’m doing this to basically ensure that it’s an absolute path. I’m basically duplicating the alias and it seems to be working. Within the SCSS files in the repo that a test they are using relative paths.

{
resolve: {
  {
      find: /^@\//,
      replacement: `${path.resolve(__dirname, 'src')}/`,
    },
},
// ...
css: {
      preprocessorOptions: {
        scss: {
          additionalData: `
            @use "sass:math";
            @import "${path.resolve(__dirname, 'src')}/styles/_variables.scss";
            @import "${path.resolve(__dirname, 'src')}/styles/_mixins.scss";
            
          `,
        },
      },
    },
 }
2reactions
ChenYCLcommented, May 19, 2022

Hello,get same issue. lerna project , i need some scss file import from theme pkg. image Have any solution solve this? thx

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sass "Error: Can't find stylesheet to import."
I finally worked around this problem by using Grunt instead of sass to compile and watch the SCSS files. After running ...
Read more >
Laravel NPM run Dev error "Can't find stylesheet to import."
So I did some googling and found out about how to using laravel mix and everything. and this compass/css3 is something they import...
Read more >
Configuring Vitest
When importing such dependencies in Node environment using named exports, ... threads (will always be '1' , if run with threads: false )....
Read more >
css-loader | webpack - JS.ORG
The css-loader interprets @import and url() like import/require() and will resolve ... Using false value increase performance because we avoid parsing CSS ......
Read more >
[Support Guide] Netlify app builds locally but fails on ...
Build failed because of webpack errors (Next.js + AWS Amplify). Typescript Build Error with Next.js. Sass Error: Can't find stylesheet to import.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found