2016-03-08 04:20:32 +01:00
|
|
|
/* ==========================================================================
|
|
|
|
MINIMAL MISTAKES JEKYLL THEME - Gulpfile
|
|
|
|
========================================================================== */
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Packages used
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var sass = require('gulp-sass');
|
|
|
|
var prefix = require('gulp-autoprefixer');
|
|
|
|
var plumber = require('gulp-plumber');
|
|
|
|
var uglify = require('gulp-uglifyjs');
|
|
|
|
var jshint = require('gulp-jshint');
|
|
|
|
var rename = require("gulp-rename");
|
|
|
|
var imagemin = require("gulp-imagemin");
|
|
|
|
var pngquant = require('imagemin-pngquant');
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Styles
|
|
|
|
* - Compile
|
|
|
|
* - Compress/Minify
|
|
|
|
* - Catch errors (gulp-plumber)
|
|
|
|
* - Run through Autoprefixer
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
gulp.task('css', function() {
|
2016-03-18 02:32:55 +01:00
|
|
|
return gulp.src('assets/scss/**/*.scss')
|
2016-03-09 18:10:43 +01:00
|
|
|
.pipe(sass({outputStyle: 'compressed'}))
|
|
|
|
.pipe(prefix('last 2 versions', '> 5%', 'ie 9'))
|
|
|
|
.pipe(plumber())
|
|
|
|
.pipe(gulp.dest('assets/css'));
|
2016-03-08 04:20:32 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Javascript
|
|
|
|
* - Concatenate main script with plugins
|
|
|
|
* - Uglify
|
|
|
|
* - Rename
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
gulp.task('scripts', function() {
|
2016-03-18 02:32:55 +01:00
|
|
|
return gulp.src(['assets/js/vendor/jquery/*.js', 'assets/js/plugins/*.js', 'assets/js/_main*.js'])
|
2016-03-08 04:20:32 +01:00
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(rename({
|
|
|
|
basename: "main",
|
|
|
|
suffix: ".min",
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('assets/js'))
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Javascript
|
|
|
|
* - Lint for errors
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
gulp.task('jslint', function() {
|
2016-03-18 02:32:55 +01:00
|
|
|
return gulp.src('assets/js/_*.js')
|
2016-03-08 04:20:32 +01:00
|
|
|
.pipe(jshint())
|
|
|
|
.pipe(jshint.reporter('default'))
|
|
|
|
.pipe(jshint.reporter('fail'))
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Images
|
|
|
|
* - Optimize image assets
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
gulp.task('images', function () {
|
|
|
|
return gulp.src('images/*')
|
2016-03-09 18:10:43 +01:00
|
|
|
.pipe(imagemin({
|
|
|
|
progressive: true,
|
|
|
|
svgoPlugins: [{removeViewBox: false}],
|
|
|
|
use: [pngquant()]
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('images'));
|
2016-03-08 04:20:32 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Default task
|
|
|
|
* - Runs scss, scripts and image tasks
|
|
|
|
* - Watches for scss, script, and image changes
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
gulp.task('default', ['css', 'jslint', 'scripts', 'images'], function () {
|
2016-03-18 02:32:55 +01:00
|
|
|
gulp.watch('assets/scss/**/*.scss', ['css']);
|
|
|
|
gulp.watch('assets/js/_*.js', ['jslint']);
|
|
|
|
gulp.watch('assets/js/**/*.js', ['scripts']);
|
2016-03-08 04:20:32 +01:00
|
|
|
gulp.watch('images/*', ['images']);
|
|
|
|
});
|