I have a gulp task that tries to convert .scss files to .css files (using gulp -ruby-sass), and then put the resulting .css file in the place where it found the source file. The problem is that since I use the template for the substitution, I donβt necessarily know where the source file is stored.
In the code below, I'm trying to use gulp -tap to access the stream and find out the file path of the current file from which the stream was read:
gulp.task('convertSass', function() { var fileLocation = ""; gulp.src("sass/**/*.scss") .pipe(sass()) .pipe(tap(function(file,t){ fileLocation = path.dirname(file.path); console.log(fileLocation); })) .pipe(gulp.dest(fileLocation)); });
Based on the output of console.log(fileLocation) , this code looks as if it should work fine. However, the resulting CSS files seem to be placed in the same directory higher than I expect. Where it should be project/sass/partials , the resulting file path is simply project/partials .
If there is a much simpler way to do this, I will definitely appreciate this decision even more. Thank!
Dan-Nolan Apr 23 '14 at 2:39 on 2014-04-23 14:39
source share