Closed aztack closed 1 month ago
This is one of the many reasons why we recommend against using @import
. Prefer using @use
instead. The documentation calls out these reasons: https://sass-lang.com/documentation/at-rules/import/
Specifically:
Each stylesheet is executed and its CSS emitted every time it’s
@import
ed, which increases compilation time and produces bloated output.
I'm trying to prevent a global variable from being re-defined (returning to the initial value) by testing its existence with
global-variable-exists
function and initializing it only if it doesn't exist (the first time imported):global.scss:
a.scss:
Here is the output of running sass a.scss:
But I got the deprecating warning above. If I add
$global: null
at the stylesheet root.$global
will be set to null every timeglobal.scss
is imported and this makes the testing pointless.Is there a recommended way to prevent a scss file from being imported multiple times?