Angular CLI : generate SASS project from existing project

标签 angular sass angular-cli

我开始处理 Angular CLI 生成的项目,然后意识到我忘记了 --style=sass 标志。 有什么方法可以转换我的项目以使用 Angular CLI 启用 SASS?

最佳答案

在 Angular 6+ 中,如果您在执行 ng config defaults.styleExt = scss 后收到控制台警告 如下图是因为single dashes are not supported anymore

Schema validation failed with the following errors:
 Data path "" should NOT have additional properties(defaults).

您可以运行以下命令来更改原理图

ng config schematics.@schematics/angular:component.styleext scss

您需要进行两次手动更改

  • 将根文件夹中的.css文件重命名为.scss
  • 使用 "styles": ["src/styles.scss"],
  • 更新 angular.json 文件

关于 Angular CLI : generate SASS project from existing project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41428437/

相关文章:

angular - Angular 为 2 的开放图

twitter-bootstrap - Bootstrap sass + gulp : Media query expression must begin with '('

visual-studio - 关于如何在 Visual Studio 中使用 sassy studio 进行编译的说明

css - child 上课时得到最后一个 child

javascript - 将函数分配给 *ngFor 中的事件处理程序

animation - 我如何在 Angular 2 中为路由器组件使用动画

angular - 尝试在 Angular 5 中使用草皮 js

angular - 如何让 angular 2 cli 将 css 和其他必要文件复制到 dist 文件夹

angular - Nativescript Angular 2 - 单击时将类添加到标签

angular - 如何处理构建 "dist"文件夹