2016-11-10 82 views
7

我使用角CLI:1.0.0-beta.19-3節點:v5.11.1angular2 - 使用引導,薩斯編譯錯誤角CLI

在我角CLI .json文件,我已將全局樣式文件擴展名設置爲.scss。

這是我的樣式文件。

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"; 

錯誤吐出來時,我嘗試導入bootrap - 薩斯模塊,它給關聯到glyphicon圖標的錯誤。不知道如何解決它。

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 

回答

13

通過一些研究後,我在這裏找到了解決方案。

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

我必須在導入引導青菜文件之前設置glyphicons圖標路徑。即。

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

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

你在哪裏 做這個? – netshark1000

0

我曾與材料設計字體

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"); 

而要做到這僅是添加了正確的方式,同樣的問題的「〜」在該行的開頭:

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"); 
0

把它放在你的.angular-cli.json中:

 "stylePreprocessorOptions": { 
      "includePaths": [ 
       "../node_modules" 
      ] 
     },