Search code examples
sass

What's the difference between only @use and @use as * SCSS rules?


What's the difference?

@use 'scss/my'

and

@use 'scss/my' as *

I think it's same, isn't no use namespace, right? but is it difference?


Solution

  • The Choosing a Namespace doc explains clearly.

    By default, a module’s namespace is just the last component of its URL without a file extension. However, sometimes you might want to choose a different namespace—you might want to use a shorter name for a module you refer to a lot, or you might be loading multiple modules with the same filename. You can do this by writing @use "<url>" as <namespace>.

    You can even load a module without a namespace by writing @use "<url>" as *. We recommend you only do this for stylesheets written by you, though; otherwise, they may introduce new members that cause name conflicts!