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

SCSS files are not compiled when being imported from CSS files #11837

Closed
7 tasks done
art-solopov opened this issue Jan 28, 2023 · 4 comments · Fixed by #8400
Closed
7 tasks done

SCSS files are not compiled when being imported from CSS files #11837

art-solopov opened this issue Jan 28, 2023 · 4 comments · Fixed by #8400

Comments

@art-solopov
Copy link

Describe the bug

When I'm trying to import an SCSS file from a CSS file, I see either:

  • An "unknown word" error from postcss-import if there are any SCSS comments;
  • A "cannot find" error from postcss-import if there are any imports inside SCSS (even though postcss-import shouldn't be handling those)
  • Untransformed SCSS being added as if it was CSS

This makes me suspect that SCSS imports from CSS aren't being transformed properly.

Reproduction

https://stackblitz.com/edit/vitejs-vite-rrleev?file=styles/button.scss

Steps to reproduce

No response

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (12) x64 AMD Ryzen 5 5600H with Radeon Graphics
    Memory: 6.88 GB / 14.99 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.12.0 - ~/.asdf/installs/nodejs/18.12.0/bin/node
    Yarn: 1.22.19 - ~/.asdf/installs/nodejs/18.12.0/bin/yarn
    npm: 8.19.2 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chromium: 109.0.5414.119
    Firefox: 109.0
  npmPackages:
    vite: ^4.0.0 => 4.0.4

Used Package Manager

yarn

Logs

No response

Validations

@cloudfroster
Copy link

cloudfroster commented Jan 29, 2023

There is a problem with your code in button.scss, it should be:

/* wrong code @import './variables'; */
@import './_variables.scss';

Need to complete the suffix and fix file name.

@art-solopov
Copy link
Author

First of all, this doesn't match Sass's import behaviour.

And second, there's still an issue of Sass code being injected into CSS without any compilation.

@TheElegantCoding
Copy link

i have this error, the varaibles are not recognize, but only happens in qwik i will put my example here.

https://github.com/LuisCoderDev/qwik-scss

also changing te imports with underscore and .scss still doenst work for me

@castrix
Copy link

castrix commented Jun 2, 2023

I'm having the same issue as well, I troubleshoot this for weeks and still haven't find the solution.
But I need to thank you now, I just found that I had a css file that import scss which causing the issue, but the error message doesn't point to the correct file, it's pointing to the other scss file.

the error looks like this:

[vite:css] [postcss] ENOENT: no such file or directory, stat '/home/castrix/myapp/variables'
file: /home/castrix/myapp/src/styles/index.scss:undefined:undefined
error during build:
Error: [postcss] ENOENT: no such file or directory, stat '/home/castrix/myapp/variables'
error Command failed with exit code 1.

But the actual issue was caused by my icons.css which has @import 'variables'

@github-actions github-actions bot locked and limited conversation to collaborators Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants