You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法创建可在所有Sass文件中复用的主题文件问题求助

目标

我希望在theme.sass中通过@use '@angular/material' as mat引入Angular Material的Sass模块,同时能在项目里其他任意Sass文件中引入并使用theme.sass。

问题

当前theme.sass的代码如下:

@use '@angular/material' as mat

@include mat.core()
$localPalette: mat.$red-palette

单独编译这个文件时没有任何报错,但当其他Sass文件(比如colors.sass)尝试通过@use "../theme" as style、@import "../theme"引入它,或者自身也使用@use "@angular/material" as mat时,就会抛出以下错误:

Error: Can't find stylesheet to import.
╷
1 │ @use '@angular/material' as mat
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
..\theme.sass 1:1 @use
colors.sass 1:1 root stylesheet

当前环境配置

  • 编辑器:最新版WebStorm
  • Sass编译命令参数:--load-path ../node_modules $FileName$:$FileNameWithoutExtension$.css

内容的提问来源于stack exchange,提问作者xRay

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 12:32:21