【问题标题】:gulp-sass wont import bootstrap installed with bowergulp-sass 不会导入安装了凉亭的引导程序
【发布时间】:2015-02-23 17:59:16
【问题描述】:

我想遍历我所有的凉亭包。所有以 sass 文件作为主要文件的文件,我想将它们包含在 includePaths 中以供 gulp-sass 使用。

我正在使用 npm 包 main-bower-files 成功获取主文件(我过滤到仅 scss 文件)。

但是当我去编译时,我得到了以下错误(因为现在我只有 bootstrap):

stream.js:94
      throw er; // Unhandled stream error in pipe.
            ^
Error: file to import not found or unreadable: bootstrap

我的 gulpfile 的相关部分是

var load_paths = bower({
  base: path.join(__dirname, "bower_components"),
  filter: '**/_*.scss'
});

gulp.src(app_css_file)
.pipe(sass({
    includePaths: load_paths
}))
.pipe(concat('app.css'))
.pipe(gulp.dest('build/css'));

【问题讨论】:

    标签: gulp bower gulp-sass


    【解决方案1】:

    我的问题原来是main-bower-files 给你文件,而不是目录。呃。 Node-sass 需要包含可导入文件的目录。

    所以我必须稍微修改一下我的load_paths

    for (var i=0; i<load_paths.length; i++){
      // we need to use the parent directories of the main files, not the files themselves
      // so ./bower_components/bootstrap-sass-official/assets/stylesheets/_bootstrap.scss
      // becomes ./bower_components/bootstrap-sass-official/assets/stylesheets
      load_paths[i] = path.dirname(load_paths[i]);
    }
    

    这就解决了。希望这对其他人有帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 2013-01-05
      • 2014-09-12
      • 2015-02-04
      • 2013-07-03
      • 2014-02-09
      • 2013-05-23
      相关资源
      最近更新 更多