I am looking to write my gulpfile.js scan the themes directory for style.scss files, and the idea is to read the style.scss file and write the corresponding style.css & .min file in the same directory. The issue that i'm having is that I can't find a way to write the css file without knowing exactly what the directory is... which I will not.
Is this possible with the gulp.dest()?
tl;dr: Essentially... how can I determine the current path of the *.scss file being processed so that I can place the *.css file in the same directory
gulpfile.js
// GULP variable declarations
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-ruby-sass'),
prefix = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify');
// Paths array
var path = {
scss: [
'docroot/profile/theme/**/*/style.scss',
],
watch_scss: [
'docroot/profile/theme/**/*.scss',
],
};
// Process SASS functionality
gulp.task('process-scss', function() {
return gulp.src(path.scss)
.pipe(sass({
compass: true,
style: 'expanded',
}))
.pipe(prefix(['last 2 versions']))
.pipe(concat('style.css'))
.pipe(gulp.dest('./relative/dir')
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('./relative/dir')
.on('error', gutil.log);
});
// Setup the gulp WATCH functionality
gulp.task('default', function() {
gulp.start('process-scss');
gulp.watch(path.watch_scss, ['process-scss']);
});