Skip to content

Instantly share code, notes, and snippets.

@RishikeshDarandale
Forked from halex2005/gulpfile.js
Created July 26, 2016 06:37
Show Gist options
  • Save RishikeshDarandale/a875d373e9208ff9e50f11a4c502dd88 to your computer and use it in GitHub Desktop.
Save RishikeshDarandale/a875d373e9208ff9e50f11a4c502dd88 to your computer and use it in GitHub Desktop.
gulpfile for codeofcliber blog
var gulp = require('gulp');
// build tasks
var childProcess = require('child_process');
gulp.task('jekyll', function(cb) {
var child = childProcess.exec('jekyll build', function(error, stdout, stderr) {
cb(error);
});
});
var htmlmin = require('gulp-htmlmin');
gulp.task('htmlmin', function() {
return gulp.src('./_site/**/*.html')
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true,
conservativeCollapse: true,
collapseBooleanAttributes: true,
removeRedundantAttributes: true,
removeEmptyAttributes: true,
removeEmptyElements: true,
lint: false,
minifyJS: true,
minifyCSS: true,
}))
.pipe(gulp.dest('./_site/'));
});
var minifycss = require('gulp-minify-css');
var autoprefixer = require('gulp-autoprefixer');
gulp.task('build-css', function() {
return gulp.src('./_site/css/*.css')
.pipe(minifycss())
.pipe(autoprefixer({
browsers: ['> 1%'],
cascade: false,
}))
.pipe(gulp.dest('./_site/css'));
});
var jsValidate = require('gulp-jsvalidate');
var uglify = require('gulp-uglify');
gulp.task('build-js', function() {
return gulp.src('./_site/js/**/*.js')
.pipe(jsValidate())
.pipe(uglify())
.pipe(gulp.dest('./site/js/'));
});
gulp.task('copy_bower_components', function() {
gulp.src([
'bower_components/bootstrap/dist/css/bootstrap.min.css',
'bower_components/bootstrap/dist/css/bootstrap-theme.min.css',
'bower_components/fontawesome/css/font-awesome.min.css',
'bower_components/normalize.css/normalize.css'
]).pipe(gulp.dest('./_site/vendor/css/'));
gulp.src([
'bower_components/bootstrap/dist/fonts/*',
'bower_components/fontawesome/fonts/*',
]).pipe(gulp.dest('./_site/vendor/fonts/'));
gulp.src([
'bower_components/bootstrap/dist/js/bootstrap.min.js',
'bower_components/jquery/dist/jquery.min.js',
]).pipe(gulp.dest('./_site/vendor/js/'));
});
gulp.task('build', [ 'jekyll' ], function() {
gulp.run('copy_bower_components');
gulp.run('build-css');
gulp.run('htmlmin');
});
// check tasks
var bootlint = require('gulp-bootlint');
var html5Lint = require('gulp-html5-lint');
var htmlhint = require("gulp-htmlhint");
gulp.task('check-html', function() {
return gulp.src('./_site/**/*.html')
.pipe(html5Lint())
.pipe(htmlhint())
.pipe(bootlint());
});
var scsslint = require('gulp-scss-lint');
gulp.task('check-scss', function() {
gulp.src([ './_sass/**/*.scss' ])
.pipe(scsslint())
});
gulp.task('check', [ 'check-html', 'check-scss' ], function() {});
// default task
gulp.task('default', [ 'build' ], function() {});
// serve task
var webserver = require('gulp-webserver');
gulp.task('serve', function() {
gulp.src('./_site/')
.pipe(webserver({
host: "localhost",
port: 4000,
open: true,
}));
});
gulp.task('run', [ 'default' ], function() {
gulp.run('serve');
});
{
"name": "hal-blog",
"version": "1.0.0",
"description": "My blog based on Jekyll",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"jekyll",
"blog"
],
"author": "halex2005",
"license": "BSD-2-Clause",
"devDependencies": {
"gulp": "~3.8.11",
"gulp-autoprefixer": "^2.1.0",
"gulp-bootlint": "~0.3.0",
"gulp-concat": "^2.5.2",
"gulp-html5-lint": "~1.0.1",
"gulp-htmlhint": "0.0.9",
"gulp-htmlmin": "~1.1.1",
"gulp-jsvalidate": "^2.0.0",
"gulp-minify-css": "~1.0.0",
"gulp-scss-lint": "^0.1.10",
"gulp-uglify": "^1.1.0",
"gulp-webserver": "^0.9.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment