-
This relates to this question and this issue. Like these people mentioned, I've been using But it appears that importing from If it's not going to be supported, how can I share variables (e.g. color values) between JS and SCSS (including in the Vue |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 15 replies
-
I found the solution 🚀 I realized that the same thing I did for a Laravel Mix 5->6 upgrade worked for Vite too, as per this Github comment of mine. The gist of it is: So rather than doing: import { primary } from './foo.module.scss'; You would need to do this instead: import foo from './foo.module.scss';
const { primary } = foo; |
Beta Was this translation helpful? Give feedback.
-
@amcsi Could you eleborate on "entire default needs to be exported" ? $primary: #893e59;
$secondary: #c88c00; But then the @import './my-palette.scss';
:export {
$primary: $primary; // does not work ???
}
|
Beta Was this translation helpful? Give feedback.
-
It works when I import the file only in the <script></script> from a .vue file like this :
But I get the error "This file is already being loaded" from Vite when I also import the file globaly in a vite.config.ts file like this :
I call it globally to use the same variables in the <style lang="scss"></style> part in a lot of files. |
Beta Was this translation helpful? Give feedback.
-
I'm having trouble getting this working vite config
js import
results in error has anyone else seen this? |
Beta Was this translation helpful? Give feedback.
-
Is anyone else having compilation warnings after this? [ see #15915 (comment) ] |
Beta Was this translation helpful? Give feedback.
I found the solution 🚀
I realized that the same thing I did for a Laravel Mix 5->6 upgrade worked for Vite too, as per this Github comment of mine.
The gist of it is:
_foo.scss
(with the exported variables) should be renamed tofoo.module.scss
, and rather than doing a destructured import of the variables from the scss file, the entire default needs to be imported, and then that can be const destructured.So rather than doing:
You would need to do this instead: