【问题标题】:Imports from external styles sheet does not work angular从外部样式表导入不起作用
【发布时间】:2019-01-22 12:53:28
【问题描述】:

我有像 external.scss 这样的外部 SASS 文件,其内容如下

@import "core/colors";

这包含在应用程序中,例如在 angular.json 文件中添加以下内容

"styles": [
          "path/external.scss",
            "styles.scss"
        ],

我尝试在我的应用程序中访问 c​​olors.scss 文件中存在的一些变量,但它显示未找到变量。我必须在我的 styles.scss 文件中再次导入 colors.scss 文件来检测变量。有没有办法阻止添加到styles.scss文件中。

【问题讨论】:

  • 在我的情况下,我只需创建 _vars.scss 并像 @import "vars"; 这样在我的 _vars.scss 代码中像 $BoxShadow: 0px 0px 12px rgba(0, 0, 0, 0.16); 一样导入并在 style.scss 中使用 box-shadow: $BoxShadow .

标签: angular


【解决方案1】:

我会使用stylePreprocessorOptions 并在includePaths 中指定一个路径数组。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多