sass file structure using @use and @forward

hi iam trying to wrap my head around sass file structure and i got lost in@use and @forwardimplementation for example my file structure is like this ; util ┣ _variable.scss ┣ _reset.scss ┣ _utilities.scss ┣ _mixins.scss ┗ _index.scss _index.scss style.scss in /util/_index.scss i use forward for every file but how can i make /util compile in /_index.scss then make accessible by /style.scss i beleive that part is done by @use,the rest couldnt figure it out .
4 Replies
reznaeous
reznaeous2w ago
Basically, in util/_index.scss you want something like:
@use "variable";
@use "reset";
@use "utilities";
@use "mixins";
@use "variable";
@use "reset";
@use "utilities";
@use "mixins";
Then in your /style.scss you would put @use util"; That basically says to go look in the util subdirectory for an _index.scss and bring in whatever is in there. I don't think there's really any need for the intermediate step of the /_index.scss file.
vince
vince2w ago
You can replace @use with @forward here, and then @use the file with the forwards
reznaeous
reznaeous2w ago
Yup, I brain farted big time. @forward is what I meant to show using in util/_index.scss instead of @use, with @use in the /style.scss Trying to juggle too many things at the same time, I think.
ilyes
ilyesOP2w ago
Thank you i like having my style.scss file clean so instead of doing @use for every folder like util pages layout ... ,i compile them all in _index.scss then @use "index" inside style.scss

Did you find this page helpful?