Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"@use rules must be written before any other rules" error occured with multiple themings #105

Open
PhilippeLafreniere18 opened this issue Aug 12, 2021 · 1 comment

Comments

@PhilippeLafreniere18
Copy link

PhilippeLafreniere18 commented Aug 12, 2021

Hi,
Our app is build with multiple themings sheets and Angular 12. A main theming file imports some and these imports some other theming files too (simple parent-children logic). I tried to use new scss-bundle rules (@use vs @import) but this scss-bundle error always occured when i tried to compile all of it :
@use rules must be written before any other rules

My main theming file is something like this :

@import './theming';
@import '../../../common/src/style/common.theming';

@mixin all-theming($theme, $typography) {
  @include theming($theme, $typography);
  @include common-theming($theme, $typography);
}

"theming" is built like this :

@use '~@angular/material' as mat;

@mixin theming($theme, $typography) {
  @include mat.core($typography);
  @include angular-material-theme($theme);

  $primary: mat.define-palette(mat.$blue-palette, 700, 400, 900);
  $accent: mat.define-palette(mat.$blue-palette, 200);
...
}

and "common-theming" looks like this :

@use '~@angular/material' as mat;

@mixin common-theming($theme) {
  $primary: map-get($theme, primary);
  $accent: map-get($theme, accent);

  entity-table {
    background-color: mat.get-color-from-palette($primary, A100);
    color: mat.get-color-from-palette($primary, default-contrast);
  }
}

I need the @use rule in each file to set namespace ("mat" in my case) and to allow the use of theming functions. What do I need to make this right ?

Here Angular12 doc for theming (https://material.angular.io/guide/theming)

Package version: v1.35.1 (sass)
Node version: v14.17.1
OS: Windows

@PopescuStefanRadu
Copy link

check out #90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants