Please include documentation on how to load node_modules paths using gulp.sass
I'm having this exact same issue!
gulp.task('sass', function(){
return gulp.src('./node_modules/foundation-sites/scss/foundation.scss')
.pipe(
sass(
{
includePaths: [
'./node_modules/foundation-sites/scss/',
]
}
)
)
.pipe(gulp.dest('./app/resources/css/'));
});
Does not work. Gulp-sass completely ignores the includes. Either I'm doing this wrong, or gulp-sass is broken right now.
you could do it like this:
var path = require("path");
function importer(url, prev, done) {
if (url[0] === '~') {
url = path.resolve('./node_modules', url.substr(1));
}
return { file: url };
}
gulp.task('scss',function() {
return gulp.src('app/style.scss')
.pipe(sass({importer:importer}))
.pipe(gulp.dest('dist'));
});
This is not possible with gulp-sass or node-sass in a safe manner. I suggesting looking a custom loader for this purpose. I suggest eyeglass. The solutions offered are naive but will work good enough in most case.
Thanks @azerafati,
Now I'm able to resolve the same path in my webpack and gulp builds without having to rewrite any file paths!
Most helpful comment
you could do it like this: