Gulpifying Jekyll
This file contains 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
/*global -$ */ | |
'use strict'; | |
// generated on 2015-06-12 using generator-gulp-webapp 0.3.0 | |
var gulp = require('gulp'); | |
var $ = require('gulp-load-plugins')(); | |
var browserSync = require('browser-sync'); | |
var reload = browserSync.reload; | |
gulp.task('styles', function () { | |
return gulp.src('app/styles/main.scss') | |
.pipe($.sourcemaps.init()) | |
.pipe($.sass({ | |
outputStyle: 'nested', // libsass doesn't support expanded yet | |
precision: 10, | |
includePaths: ['.'], | |
onError: console.error.bind(console, 'Sass error:') | |
})) | |
.pipe($.postcss([ | |
require('autoprefixer-core')({browsers: ['last 1 version']}) | |
])) | |
.pipe($.sourcemaps.write()) | |
.pipe(gulp.dest('.tmp/styles')) | |
.pipe(reload({stream: true})); | |
}); | |
gulp.task('jshint', function () { | |
return gulp.src('app/scripts/**/*.js') | |
.pipe(reload({stream: true, once: true})) | |
.pipe($.jshint()) | |
.pipe($.jshint.reporter('jshint-stylish')) | |
.pipe($.if(!browserSync.active, $.jshint.reporter('fail'))); | |
}); | |
gulp.task('html', ['styles'], function () { | |
var assets = $.useref.assets({searchPath: ['.tmp', 'app', '.']}); | |
return gulp.src('app/*.html') | |
.pipe(assets) | |
.pipe($.if('*.js', $.uglify())) | |
.pipe($.if('*.css', $.csso())) | |
.pipe(assets.restore()) | |
.pipe($.useref()) | |
.pipe($.if('*.html', $.minifyHtml({conditionals: true, loose: true}))) | |
.pipe(gulp.dest('dist')); | |
}); | |
gulp.task('images', function () { | |
return gulp.src('app/images/**/*') | |
.pipe($.cache($.imagemin({ | |
progressive: true, | |
interlaced: true, | |
// don't remove IDs from SVGs, they are often used | |
// as hooks for embedding and styling | |
svgoPlugins: [{cleanupIDs: false}] | |
}))) | |
.pipe(gulp.dest('dist/images')); | |
}); | |
gulp.task('fonts', function () { | |
return gulp.src(require('main-bower-files')({ | |
filter: '**/*.{eot,svg,ttf,woff,woff2}' | |
}).concat('app/fonts/**/*')) | |
.pipe(gulp.dest('.tmp/fonts')) | |
.pipe(gulp.dest('dist/fonts')); | |
}); | |
gulp.task('extras', function () { | |
return gulp.src([ | |
'app/*.*', | |
'!app/*.html' | |
], { | |
dot: true | |
}).pipe(gulp.dest('dist')); | |
}); | |
gulp.task('clean', require('del').bind(null, ['.tmp', 'dist'])); | |
gulp.task('serve', ['styles', 'fonts'], function () { | |
browserSync({ | |
notify: false, | |
port: 9000, | |
server: { | |
baseDir: ['.tmp', 'app'], | |
routes: { | |
'/bower_components': 'bower_components' | |
} | |
} | |
}); | |
// watch for changes | |
gulp.watch([ | |
'app/*.html', | |
'app/scripts/**/*.js', | |
'app/images/**/*', | |
'.tmp/fonts/**/*' | |
]).on('change', reload); | |
gulp.watch('app/styles/**/*.scss', ['styles']); | |
gulp.watch('app/fonts/**/*', ['fonts']); | |
gulp.watch('bower.json', ['wiredep', 'fonts']); | |
}); | |
// inject bower components | |
gulp.task('wiredep', function () { | |
var wiredep = require('wiredep').stream; | |
gulp.src('app/styles/*.scss') | |
.pipe(wiredep({ | |
ignorePath: /^(\.\.\/)+/ | |
})) | |
.pipe(gulp.dest('app/styles')); | |
gulp.src('app/*.html') | |
.pipe(wiredep({ | |
exclude: ['bootstrap-sass-official'], | |
ignorePath: /^(\.\.\/)*\.\./ | |
})) | |
.pipe(gulp.dest('app')); | |
}); | |
gulp.task('build', ['jshint', 'html', 'images', 'fonts', 'extras'], function () { | |
return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true})); | |
}); | |
gulp.task('default', ['clean'], function () { | |
gulp.start('build'); | |
}); |
This file contains 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
{ | |
"private": true, | |
"engines": { | |
"node": ">=0.10.0" | |
}, | |
"devDependencies": { | |
"autoprefixer-core": "^4.0.2", | |
"browser-sync": "^1.8.2", | |
"del": "^1.1.1", | |
"gulp": "^3.6.0", | |
"gulp-cache": "^0.2.2", | |
"gulp-csso": "^0.2.6", | |
"gulp-if": "^1.2.1", | |
"gulp-imagemin": "^2.0.0", | |
"gulp-jshint": "^1.5.3", | |
"gulp-load-plugins": "^0.8.0", | |
"gulp-minify-html": "^0.1.6", | |
"gulp-postcss": "^3.0.0", | |
"gulp-sass": "^1.3.3", | |
"gulp-size": "^1.1.0", | |
"gulp-sourcemaps": "^1.3.0", | |
"gulp-uglify": "^1.0.1", | |
"gulp-useref": "^1.0.2", | |
"jshint-stylish": "^1.0.0", | |
"main-bower-files": "^2.5.0", | |
"opn": "^1.0.0", | |
"wiredep": "^2.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can I see your
_config.yml
?