Created
January 26, 2014 15:00
-
-
Save markgoodyear/8634042 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Styles | |
gulp.task('styles', function() { | |
return gulp.src(config.sources.styles) | |
.pipe(sass({ errLogToConsole: true, outputStyle: 'expanded' })) | |
.pipe(prefix('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) | |
.pipe(gulpif(isProduction, mincss({ keepSpecialComments: 0 }))) | |
.pipe(header(banner)) | |
.pipe(gulp.dest(config.output.styles)) | |
.pipe(reload(server)); | |
}); | |
// Scripts | |
gulp.task('scripts', function() { | |
return gulp.src(config.sources.scripts) | |
.pipe(jshint('.jshintrc')) | |
.pipe(jshint.reporter(stylish)) | |
.pipe(concat('main.js')) | |
.pipe(gulpif(isProduction, uglify())) | |
.pipe(header(banner)) | |
.pipe(gulp.dest(config.output.scripts)) | |
.pipe(reload(server)) | |
}); | |
// Images | |
gulp.task('images', function() { | |
return gulp.src(config.sources.images) | |
.pipe(imagemin({ | |
optimizationLevel: 5, | |
progressive: true, | |
interlaced: true | |
})) | |
.pipe(gulp.dest(config.output.images)) | |
.pipe(reload(server)) | |
}); | |
// Clean assets | |
gulp.task('clean', function(cb) { | |
return gulp.src('./src/assets', {read: false}) | |
.pipe(clean()); | |
cb() | |
}); | |
// The Gulp 3.5 way, no gulp.run(); | |
// No guarantee clean will be complete | |
gulp.task('build', ['clean', 'styles', 'scripts', 'images']); | |
// The pre-Gulp 3.5 way | |
// Clean will be complete beforehand | |
gulp.task('build', ['clean'], function() { | |
gulp.run('styles', 'scripts', 'images'); | |
}) | |
/** | |
* What would be considered best practice for ensuring clean is fully complete | |
* and finished before running other tasks? I want to be able to run `styles`, `scripts`, `images` | |
* without depending on `clean` — I only want to clean when then `build` task is executed. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment