Replace @import with @use rules as the import rules will be deprecated later this year #712
Replace @import with @use rules as the import rules will be deprecated later this year #712
Conversation
Work in progress. Currently this addresses almost all of the |
In addition, each of the @use "mixins" as *; // no namespace to reference
@use "vars" as *;
.some-class {
color: $mdn-neutral600;
@include sr-only();
} instead of having to reference namespaces like below (the directory name) or with @use "mixins"; // namespace is mixins
@use "vars"; // namespace is vars
.some-class {
color: vars.$mdn-netural600;
@include mixins.sr-only();
} Sass Docs: |
The transition from I know this is a big overhaul, but with the end of the year approaching ( |
Wrangling to get tests passing in |
test/sass/test.scss
Outdated
@use "../../sass/mixins/utils"; | ||
|
||
@use "../../sass/atoms/buttons" as *; | ||
@use "../../sass/vars/" as *; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where using index files are super nice! We can simply import the entire directory of stylesheets as a single module rather than worrying about using the "expected" ones which sometimes can be a pain to keep track of.
Voila! Tests are passing with the overhaul to There are only 4 test.scss /* Requirements */
@use "true" as *;
@use "../../sass/mixins" as *;
@use "../../sass/atoms/" as *;
@use "../../sass/vars/" as *;
/* Tests */
@import "./test-mixins-buttons";
@import "./test-mixins-links";
@import "./test-mixins-typography";
@import "./test-mixins-utils"; |
When I try using I think the reason ping for review @schalkneethling |
Thank you, @tannerdolby. I will dig into this as soon as possible. |
Your welcome @schalkneethling! Ok sounds good. |
One thing I noticed while developing on my own site (not applicable here because we don't use any styles after the I noticed that since // style.scss (to be compiled)
@use "foo" as *;
@use "media" as *;
.some-class-that-overrides-media-query-stuff {
...
} this makes importing a module full of media query stylesheets like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so, so much for this @tannerdolby
Your welcome @schalkneethling! 🎉 |
Fixes #707