I want to write my gulpfile.js, scan the theme directory for style.scss files, and the idea is to read the style.scss file and write the corresponding style.css and .min files in the same directory. The problem I am facing is that I cannot find a way to write a css file without knowing exactly what the directory is ... which I will not.
Is this possible with gulp.dest ()?
tl; dr: Essentially ... how can I determine the current path of the processed * .scss file so that I can put the * .css file in the same directory
gulpfile.js
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');
var path = {
scss: [
'docroot/profile/theme/**/*/style.scss',
],
watch_scss: [
'docroot/profile/theme/**/*.scss',
],
};
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);
});
gulp.task('default', function() {
gulp.start('process-scss');
gulp.watch(path.watch_scss, ['process-scss']);
});
source
share