【问题标题】:Grunt watch can't compile .scss, unable to find sass-bootstrap/lib/bootstrapGrunt watch 无法编译 .scss,找不到 sass-bootstrap/lib/bootstrap
【发布时间】:2014-03-14 03:29:40
【问题描述】:

我使用 Yeoman、Bower 和 Grunt (npm install -g yo grunt-cli bower) 设置了一个快速应用程序。我安装了 AngularJS 生成器 (npm install -g generator-angular) 并运行 yo angular 来设置项目目录。最后安装 Angular 的 Bootstrap (bower install angular-bootstrap --save)。

当我运行grunt server --force 时,我看到作为项目样式目录一部分的.scss 没有被编译为.css。相反,给出了这个错误:

Syntax error: File to import not found or unreadable: sass-bootstrap/lib/bootstrap.
          Load path: C:/Users/C8M9S/Desktop/myAngular/app/styles
    on line 3 of main.scss

1: $icon-font-path: "/bower_components/sass-bootstrap/fonts/";
2: 
3: @import 'sass-bootstrap/lib/bootstrap';

任何想法为什么不编译?

【问题讨论】:

    标签: twitter-bootstrap sass gruntjs yeoman


    【解决方案1】:

    但错误显示在第 3 行,第 3 行的代码甚至没有使用 $icon-font-path! 我有一个类似的问题,解决方案是修改 Gruntfile.js 配置以告诉 grunt 组件在哪里使用 'loadPath' 参数:

    grunt.initConfig({
      sass: {
        dist: {
          options: {
            style: 'expanded',
              loadPath: 'bower_components/foundation/scss'
            },
            files: {
               'public/static/css/main.css': 'app/frontend/scss/foundation.scss'
            }
          }
    

    现在,如果在foundations.scss 中有以下行: @import "基础/组件/手风琴"

    它在以下位置查找手风琴组件:bower_components/foundation/scss/foundation/components/accordion

    希望这会有所帮助:)

    【讨论】:

      【解决方案2】:
      $icon-font-path: "/bower_components/sass-bootstrap/fonts/";
      

      正在寻找整个文件系统根目录下的 bower_components 文件夹。删除开头的 / 并找出您的 sass 文件所在的 bower components 文件夹的相对文件路径是什么。像这样的:

      $icon-font-path: "../../bower_components/sass-bootstrap/fonts/";
      

      【讨论】:

      • 我在最新的角度生成器中发现了这个问题
      猜你喜欢
      • 2017-03-16
      • 2018-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多