10

I am using angular-cli: 1.0.0-beta.19-3 with node: v5.11.1

In my angular-cli.json file, i have set the global style file extension to .scss.

Here is my styles file.

angular2/src/styles.scss

// Default Font
@import url(https://fonts.googleapis.com/css?family=Raleway:300,400,600);

// Typography
$font-family-sans-serif: "Raleway", sans-serif;
$font-size-base: 14px;
$line-height-base: 1.6;
$text-color: #636b6f;

// Import bootstrap
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";

Errors spits out when I try to import bootrap-sass modules, it gives an error associated to glyphicon icons. Don't know how to resolve it.

ERROR in ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss
Module not found: Error: Can't resolve '../fonts/bootstrap/glyphicons-halflings-regular.eot' in '/var/www/angular/src'
 @ ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss 6:4253-4315 6:4338-4400
 @ ./src/styles.scss
 @ multi styles

ERROR in ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss
Module not found: Error: Can't resolve '../fonts/bootstrap/glyphicons-halflings-regular.woff2' in '/var/www/angular2/src'
 @ ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss 6:4452-4516
 @ ./src/styles.scss
 @ multi styles

ERROR in ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss
Module not found: Error: Can't resolve '../fonts/bootstrap/glyphicons-halflings-regular.woff' in '/var/www/angular2/src'
 @ ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss 6:4549-4612
 @ ./src/styles.scss
 @ multi styles

ERROR in ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss
Module not found: Error: Can't resolve '../fonts/bootstrap/glyphicons-halflings-regular.ttf' in '/var/www/angular2/src'
 @ ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss 6:4644-4706
 @ ./src/styles.scss
 @ multi styles

ERROR in ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss
Module not found: Error: Can't resolve '../fonts/bootstrap/glyphicons-halflings-regular.svg' in '/var/www/angular2/src'
 @ ./~/css-loader!./~/postcss-loader!./~/sass-loader!./src/styles.scss 6:4742-4804
 @ ./src/styles.scss
 @ multi styles
Dipendra Gurung
  • 5,720
  • 11
  • 39
  • 62

3 Answers3

17

After going through some research, I found solution here.

https://github.com/angular/angular-cli/issues/2170

I must set the icon path for glyphicons before importing bootstrap sass files. ie.

$icon-font-path: '~bootstrap-sass/assets/fonts/bootstrap/';

// Import bootstrap
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
Dipendra Gurung
  • 5,720
  • 11
  • 39
  • 62
0

I had the same problem with material design fonts

src: url("../font/material-design-icons/Material-Design-Icons.eot?#iefix") format("embedded-opentype"), url("../font/material-design-icons/Material-Design-Icons.woff") format("woff"), url("../font/material-design-icons/Material-Design-Icons.ttf") format("truetype"), url("../font/material-design-icons/Material-Design-Icons.svg#Material-Design-Icons") format("svg");

And the correct way to do it were just adding an "~" at the beginning of the line:

src: url("~/font/material-design-icons/Material-Design-Icons.eot?#iefix") format("embedded-opentype"), url("../font/material-design-icons/Material-Design-Icons.woff") format("woff"), url("../font/material-design-icons/Material-Design-Icons.ttf") format("truetype"), url("../font/material-design-icons/Material-Design-Icons.svg#Material-Design-Icons") format("svg");
carlitos
  • 76
  • 5
0

Put this in your .angular-cli.json:

        "stylePreprocessorOptions": {
            "includePaths": [
                "../node_modules"
            ]
        },
TargunTech
  • 1,132
  • 11
  • 19