Moar changes to the gulp process
This commit is contained in:
parent
2a51ab0c6c
commit
4331186cca
74
gulpfile.js
74
gulpfile.js
@ -9,10 +9,14 @@ var del = require('del'),
|
||||
plumber = require('gulp-plumber'),
|
||||
rename = require('gulp-rename');
|
||||
|
||||
var Config = {
|
||||
inputDir: '_source',
|
||||
outputDir: '_dist'
|
||||
}
|
||||
|
||||
var sassConfig = {
|
||||
inputDirectory: '_source/sass/**/*.scss',
|
||||
outputDirectory: '_dist/css',
|
||||
var SassConfig = {
|
||||
inputDir: '_source/sass/**/*.scss',
|
||||
outputDir: '_dist/css',
|
||||
options: {
|
||||
outputStyle: 'expanded'
|
||||
},
|
||||
@ -23,46 +27,68 @@ var sassConfig = {
|
||||
|
||||
// clean the folders
|
||||
gulp.task('clean', function(cb) {
|
||||
return del([sassConfig.outputDirectory + '/*'], cb)
|
||||
});
|
||||
|
||||
// watcher
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch(sassConfig.inputDirectory, ['sass']);
|
||||
livereload.listen()
|
||||
return del([Config.outputDir], cb)
|
||||
});
|
||||
|
||||
// render SASS
|
||||
gulp.task('sass', function() {var onError = function(err) {
|
||||
notify.onError({
|
||||
title: "Gulp",
|
||||
subtitle: "Failure!",
|
||||
message: "Error: <%= error.message %>",
|
||||
sound: "Submarine"
|
||||
title: 'gulp',
|
||||
subtitle: 'Error!',
|
||||
message: '❌ <%= error.message %>',
|
||||
sound: 'Submarine'
|
||||
})(err);
|
||||
this.emit('end');
|
||||
};
|
||||
return gulp
|
||||
.src(sassConfig.inputDirectory)
|
||||
.src(SassConfig.inputDir)
|
||||
.pipe(plumber({errorHandler: onError}))
|
||||
.pipe(sass(sassConfig.options).on('error', sass.logError))
|
||||
.pipe(autoprefixer(sassConfig.autoprefixer))
|
||||
.pipe(gulp.dest(sassConfig.outputDirectory))
|
||||
.pipe(sass(SassConfig.options).on('error', sass.logError))
|
||||
.pipe(autoprefixer(SassConfig.autoprefixer))
|
||||
.pipe(gulp.dest(SassConfig.outputDir))
|
||||
.pipe(cssnano())
|
||||
.pipe(rename({suffix: '.min'}))
|
||||
.pipe(gulp.dest(sassConfig.outputDirectory))
|
||||
.pipe(notify({ message: 'SASS rendered' }))
|
||||
.pipe(gulp.dest(SassConfig.outputDir))
|
||||
.pipe(notify({
|
||||
title: 'gulp',
|
||||
subtitle: 'Success!',
|
||||
message: 'SASS compiled ✅',
|
||||
timeout: '2'
|
||||
}))
|
||||
.pipe(livereload());
|
||||
});
|
||||
|
||||
gulp.task('sass-only', function() {
|
||||
return gulp
|
||||
.src(sassConfig.inputDirectory)
|
||||
.pipe(sass(sassConfig.options).on('error', sass.logError))
|
||||
.pipe(gulp.dest(sassConfig.outputDirectory));
|
||||
.src(SassConfig.inputDir)
|
||||
.pipe(sass(SassConfig.options).on('error', sass.logError))
|
||||
.pipe(gulp.dest(SassConfig.outputDir));
|
||||
});
|
||||
|
||||
// Copy those other files
|
||||
gulp.task('copy', function() {
|
||||
gulp.src([Config.inputDir + '/*.*'])
|
||||
.pipe(gulp.dest(Config.outputDir))
|
||||
.pipe(livereload())
|
||||
gulp.src([Config.inputDir + '/inc/**/*'])
|
||||
.pipe(gulp.dest(Config.outputDir + '/inc'))
|
||||
.pipe(livereload())
|
||||
gulp.src([Config.inputDir + '/js/**/*.*'])
|
||||
.pipe(gulp.dest(Config.outputDir + '/js'))
|
||||
.pipe(livereload())
|
||||
})
|
||||
|
||||
gulp.task('watch', function() {
|
||||
livereload.listen()
|
||||
|
||||
// Watch .scss files
|
||||
gulp.watch(SassConfig.inputDir, ['sass']);
|
||||
// Watch php files
|
||||
gulp.watch(Config.inputDir + '/*.php', ['copy'])
|
||||
gulp.watch(Config.inputDir + '/inc/*.php', ['copy']);
|
||||
});
|
||||
|
||||
// Default: First 'clean', then the rest
|
||||
gulp.task('default', ['clean'], function() {
|
||||
gulp.start('sass');
|
||||
gulp.start('sass', 'copy');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user