Reputation: 2031
I have this gulpfile.js file.
Here, you can see that every .scss file is converted to the corresponding .css file but I want all .scss files will be converted to only one .css file which will be main.css. How can I do this?
var gulp = require('gulp');
var sass = require('gulp-sass');
var browserSync = require('browser-sync').create();
gulp.task('sass', function() {
return gulp.src('app/scss/**/*.scss')
.pipe(sass())
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('browserSync', function(done) {
browserSync.init({
server: {
baseDir: 'app'
},
});
done();
})
gulp.task('watch', gulp.series('browserSync', 'sass', function() {
gulp.watch('app/scss/**/*.scss', gulp.series('sass'));
gulp.watch("app/*.html", { events: 'all' }, function(cb) {
browserSync.reload();
cb();
});
gulp.watch('app/js/**/*.js', browserSync.reload);
}));
Upvotes: 1
Views: 2106
Reputation: 308
have you tried putting in a concat before the piping in a destination? You'll need to import the concat function found here. The following should combine your files.
gulp.task('sass', function() {
return gulp.src('app/scss/**/*.scss')
.pipe(sass())
// concat will combine all files declared in your "src"
.pipe(concat('all.scss'))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({
stream: true
}))
});
Upvotes: 3