简体   繁体   English

使用Angular 2 CLI进行SASS Mixins

[英]SASS Mixins with Angular 2 CLI

I am excited about the new Angular CLI tool and am currently adjusting my MEAN stack to use its folder structure. 我对新的Angular CLI工具感到兴奋,目前正在调整我的MEAN堆栈以使用其文件夹结构。 I setup my app to use SCSS instead of css as I love SASS. 我设置我的应用程序使用SCSS而不是css,因为我喜欢SASS。

However the main styles.scss that should work as global doesn't seem to load in the mixins for use in the other scss files. 但是,应该作为全局工作的主要styles.scss似乎不会在mixins中加载以用于其他scss文件。 My styles.scss looks like this: 我的styles.scss看起来像这样:

STYLES.SCSS STYLES.SCSS

    //Compass Import
    @import "compass";
    @import "compass/reset";
    @import "compass/css3/box-shadow";
    @import "compass/css3/text-shadow";
    @import "compass/css3/filter";
    @import "compass/css3/flexbox";
    @import "compass/css3/transition";

    //External Libraries

    @import "susy";
    @import "breakpoint";


    //Core Partials
    @import "scss/variables";
    @import "scss/base";
    @import "scss/mixins";
    @import "scss/layout";

    //Modules

    @import "modules/myApp";

My SCSS files for my components use @includes for things like breakpoint and susy however I get an error that says it can't find "Container", however susy is installed and imported in the styles.scss . 我的组件的我的SCSS文件使用@includes作为断点和susy之类的东西但是我得到一个错误,说它找不到“容器”,但是在styles.scss中安装并导入了susy

Error 错误

ERROR in ./src/app/app.component.scss
Module build failed:
        @include container;
         ^
      No mixin named container

Backtrace:
        stdin:3
      in C:\Users\Allie\Desktop\HWADatabase\src\app\app.component.scss (line 3, column 11)
 @ ./src/app/app.component.ts 26:21-52
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

ERROR in ./~/css-loader?{"sourceMap":false}!./~/postcss-loader!./~/sass-loader!./src/styles.scss
Module build failed:
@import "compass";
^
      File to import not found or unreadable: compass.
Parent style sheet: stdin
      in C:\Users\Allie\Desktop\HWADatabase\src\styles.scss (line 2, column 1)
 @ ./src/styles.scss 4:14-181
 @ multi ./src/styles.scss

确保通过运行以下命令设置全局默认样式:

ng set defaults.styleExt scss

Looks like Angular can't find Compass... 看起来Angular找不到指南针......

Check this thread out: https://github.com/angular/angular-cli/issues/2115 Try installing the compass-mixins via npm 检查这个帖子: https//github.com/angular/angular-cli/issues/2115尝试通过npm安装指南针mixins

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM