-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
Help WantedResolution: Needs InvestigationThis PR or Issue should be investigated from the Stencil teamThis PR or Issue should be investigated from the Stencil team
Description
Lets say I have the following setup:
{
injectGlobalPaths: ['./mixins.scss']
}
### mixins.scss
@mixin whatever {
margin: 0;
}
### styles.scss
use "sass:math";
div {
width: math.div(100, 2);
}
This will end up with error: @use rules must be written before any other rules.
https://sass-lang.com/documentation/at-rules/use
The code which adds the import statements, should analyze the file and add import clauses under @use
statements instead of just adding them to beginning of the each file.
https://github.com/ionic-team/stencil-sass/blob/7871073e3a882af4bf9a8fc7bf4faf6092828ee4/src/util.ts#L55
andrejpavlovic, kalongthewires, Schwobaland, alexregier, ethanbdev and 14 more
Metadata
Metadata
Assignees
Labels
Help WantedResolution: Needs InvestigationThis PR or Issue should be investigated from the Stencil teamThis PR or Issue should be investigated from the Stencil team
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
andrejpavlovic commentedon Nov 18, 2021
As a workaround I removed the use of
injectGlobalPaths
and now import global scss files (such asmixins.scss
) directly inside of component styles (such asstyles.scss
).A143447 commentedon Nov 29, 2021
Our workaround was to create a workaround-scss file that performs the calculations, assigning them to variables and importing that file in the
mixins.scss
. It's a bit of a hack, we only had seven instances where that calculation was needed (as opposed to many more.scss
files)r3dDoX commentedon Jan 28, 2022
Just ran in the same issue. Since we have quite a big project these workarounds are not a good option for us. Is anyone working on this?
nickjwilde commentedon Oct 7, 2022
We had this same issue as well. Looking into @lennu reference to https://github.com/ionic-team/stencil-sass/blob/7871073e3a882af4bf9a8fc7bf4faf6092828ee4/src/util.ts#L55
Switching that line to
Worked for me. However, this makes injected global paths use a namespace, so
Ends up with a colors namespace as per docs https://sass-lang.com/documentation/at-rules/use#choosing-a-namespace
Using
Removes the namespace if that's needed to make updating easier/more seamless.
I'd be happy to help with this issue.
Edits: formatting
lock stenciljs/sass to 3.0.12 (see stenciljs/sass#70); move from yarn…
lock stenciljs/sass to 3.0.12 (see stenciljs/sass#70); move from yarn…
lock stenciljs/sass to 3.0.12 (see stenciljs/sass#70); move from yarn…
mm-georges commentedon Mar 13, 2025
@christian-bromann I can contribute with a fix for that. I would go with the same approach as @nickjwilde mentioned by changing the line to
return "@use "${injectGlobalPath}" as *${importTerminator}";
xofromthemoon commentedon Apr 10, 2025
#605
janina-bro commentedon Apr 25, 2025
I ran into a similar problem regarding
injectGlobalPaths
and@use
.Using the
injectGlobalPaths
option instencil.config.ts
makes the listed SCSS files available in every component. Since@import
is deprecated, and this behavior was updated in version 3.2.1 of @stencil/sass, the plugin now uses@use
instead.However,
@use
behaves differently: it introduces namespaces, and its contents are not globally accessible unless explicitly referenced via a namespace. If the same namespace is used multiple times without a unique alias, it can lead to build errors in Stencil or Storybook.Furthermore, even if SCSS files are included via
injectGlobalPaths
, they still need to be explicitly referenced using their namespace in each component’s stylesheet. See the following example structure: