首页 > 解决方案 > 如何修复来自 Nebular Auth 的构建 sass 文件

问题描述

如果您尝试仅安装Nebular Auth Module,则可能会在下面遇到此错误。

Error: ./src/styles.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Undefined mixin.
  ╷
5 │ ┌ @include nb-install() {
6 │ │     @include nb-theme-global();
7 │ │     @include nb-auth-global();
8 │ │ };
  │ └─^
  ╵
  src/styles.scss 5:1  root stylesheet

该怎么办?

标签: angularauthenticationsassmodulenebular

解决方案


解决方案是创建一个src/themes.scss这样的文件:

@import '~@nebular/theme/styles/theming';
@import '~@nebular/theme/styles/themes/default';

$nb-themes: nb-register-theme((), default, default);

并将此导入添加到src/styles.scss

@import 'themes';

@import "~@nebular/theme/styles/globals";
@import '~@nebular/auth/styles/globals';

@include nb-install() {
    @include nb-theme-global();
    @include nb-auth-global();
};

确保您已nebular theme css导入angular.json

"styles": [
    "node_modules/@nebular/theme/styles/prebuilt/default.css",
    "src/styles.scss"
],

推荐阅读