Answer the question
In order to leave comments, you need to log in
How do I generate css relative to scss file?
When generating css it creates unnecessary nesting inside the destination folder, here is my gulpfile:
var path = require("path");
var gulp = require('gulp'),
sass = require('gulp-sass'),
rename = require("gulp-rename"),
flatten = require('gulp-flatten');
gulp.task('sass', function () {
return gulp.src('../www/local/**/sass/*.scss')
.pipe(sass())
.pipe(flatten({ includeParents: 0} ))
.pipe( gulp.dest( function( file ) { return path.join(path.dirname(file.path), '../gulp/'); } ) );
});
gulp.task('watch', function () {
gulp.watch('../www/local/**/sass/*.scss', ['sass']);
});
Answer the question
In order to leave comments, you need to log in
gulp.task('sass', function () {
gulp.src('**/sass/*.scss')
.pipe(plumber({errorHandler: onError}))
.pipe(sass())
.pipe(flatten({includeParents: 0}))
.pipe(gulp.dest(function (file) {
var dir = path.dirname(file.path).split('/scss')
return dir[1] ? path.join(dir[0], 'css', dir[1]) : path.join(dir[0], 'css');
}))
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question