gulp-sass work around for load_path support?
Asked Answered
O

1

10

Problem: I'm using gulp-sass and would like to define a load_path so that I don't have to have really long @import rules voor bower dependencies e.g.

@import "normalize"

instead of

@import "../../../../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/normalize"

What is the best way to i achieve this when using gulp-sass which uses the LibSass engine to process sass files?

Overland answered 28/8, 2015 at 7:1 Comment(4)
Possible duplicate: #24870827Pood
This is not a duplicate question because in the example provided, the developer uses gulp-ruby-sass which is different to gulp-sass in that this variant does not use ruby but instead uses libsass — a re-implementation of Sass in C++.Overland
The fact that the language the Sass compiler was written in is irrelevant, does the solution work?Pood
btw. Thanx for your helping out. But the reason the implementation does matter is because the feature support is different. As far as I can make out, load_path — as a gulp option — is not supported. I need to figure out a way around this current limitation.Overland
N
27

After struggling with this myself I found a option in gulp-sass :

sass({includePaths: ['./bower_components/bootstrap-sass/assets/stylesheets']})

Example:

var gulp = require('gulp'),
    sass = require('gulp-sass')
    notify = require("gulp-notify");

var config = {
    sassPath: './resources/sass',   // store the sass files I create
    bowerDir: './bower_components'
}

gulp.task('css', function() {
  return gulp.src(config.sassPath + '/style.scss')
    .pipe(sass({
        outputStyle: 'compressed',
        includePaths: [
            './resources/sass',
            config.bowerDir + '/bootstrap-sass/assets/stylesheets',
            config.bowerDir + '/font-awesome/scss']
        })
       .on("error", notify.onError(function (error) {
            return "Error: " + error.message;
        })))
    .pipe(gulp.dest('./public/css'));
});
Norite answered 20/11, 2015 at 15:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.