How to import file with mixins globally in angular 19?

Discussão em 'Angular' iniciado por dmytro, Março 15, 2025.

  1. dmytro

    dmytro Guest

    src/style.scss file:

    @use 'styles/normalize';
    @use 'styles/fonts';
    @use 'styles/mixins';
    @use 'styles/media';
    @use 'styles/variables';
    @use 'styles/utils';
    @use 'styles/globals';


    src/style/ folder contains:


    _fonts.scss
    _globals.scss
    _media.scss
    _mixins.scss
    _normalize.scss
    _utils.scss
    _variables.scss


    trying to use mixin from _mixins.scss (in component.scss) it throws error

    .search__button {
    @include reset-button;
    }


    ✘ [ERROR] Undefined mixin.
    ╷
    23 │ @include reset-button;
    │ ^^^^^^^^^^^^^^^^^^^^^
    ╵
    src/app/shared/components/search/search.component.scss 23:3 root stylesheet [plugin angular-sass]


    I can remove @use 'styles/mixins' from src/style.scss and import with '@use' directly in component (also in angular.json) - it will works. But I think exist a more clean way.

    Exist way to import it in style.scss (globally) and after to use whenever I want?

    Continue reading...

Compartilhe esta Página