Given the new module system in SASS (https://sass-lang.com/blog/the-module-system-is-launched) and their plans on phasing out @import
, I'm changing my @import
s to @use
s. I've been successful in most cases, but I've run into one hiccup: I currently use @import url('https://fonts.googleapis.com/css?family=Montserrat&display=swap')
to import the Montserrat typeface into my code, and I don't know how to accomplish this with @use
. I've tried the following:
@use url('https://fonts.googleapis.com/css?family=Montserrat&display=swap')
@use "url('https://fonts.googleapis.com/css?family=Montserrat&display=swap')"
@use 'https://fonts.googleapis.com/css?family=Montserrat&display=swap'
All of those give me a SASS compilation error. How do I use @use
in this case?
@import "https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;600;700&display=swap"; give the same, exact result compiled from Sass to CSS. Then, if you add one of these in a . scss file, you don't have to worry at all.
The replacement of @import
for @use
/@forward
is specifically so that the Sass version of the import function no longer shares custody with the vanilla CSS version of it.
In this instance, you're trying to use the vanilla functionality, so @import url('https://fonts.googleapis.com/css?family=Montserrat&display=swap')
is the correct syntax to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With