Last active
February 8, 2017 18:07
-
-
Save heroheman/70ef1166a7d02af97cef to your computer and use it in GitHub Desktop.
Gulpfile: Kirby // woah, this is number 2 in google search. Please don't use this one, its really outdated.
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
'use strict'; | |
var gulp = require('gulp'), | |
$ = require('gulp-load-plugins')(); | |
// Express Vars | |
var EXPRESS_PORT = 4000, | |
EXPRESS_ROOT = __dirname + '/bin', | |
LIVERELOAD_PORT = 35729; | |
// Start Express | |
function startExpress() { | |
var express = require('express'); | |
var app = express(); | |
app.use(require('connect-livereload')()); | |
app.use(express.static(EXPRESS_ROOT)); | |
app.listen(EXPRESS_PORT); | |
} | |
// Start Livereload | |
var lr; | |
function startLivereload() { | |
console.log('LiveReload Started at Port ' + LIVERELOAD_PORT); | |
lr = require('tiny-lr')(); | |
lr.listen(LIVERELOAD_PORT); | |
} | |
function notifyLivereload(event) { | |
gulp.src(event.path, {read: false}) | |
.pipe($.livereload(lr)); | |
} | |
// Styles | |
gulp.task('styles', function () { | |
return gulp.src('assets/styles/main.scss') | |
.pipe($.sass({ | |
style: 'expanded', | |
// sourceComments: 'map', | |
includePaths: ['assets/styles'], | |
errLogToConsole: true | |
})) | |
.pipe($.autoprefixer("last 1 version", "> 1%", "ie 8", "ie 7", { cascade: true })) | |
.pipe(gulp.dest('assets/styles')) | |
.pipe($.size()); | |
}); | |
// Scripts | |
gulp.task('scripts', function () { | |
return gulp.src('assets/scripts/**/*.js') | |
.pipe($.jshint('.jshintrc')) | |
.pipe($.jshint.reporter('jshint-stylish')) | |
.pipe($.size()); | |
}); | |
// Images | |
gulp.task('images', function () { | |
return gulp.src('assets/images/**/*') | |
.pipe($.cache($.imagemin({ | |
optimizationLevel: 3, | |
progressive: true, | |
interlaced: true | |
}))) | |
.pipe(gulp.dest('assets/images')) | |
.pipe($.size()); | |
}); | |
// Watch | |
gulp.task('watch', function () { | |
startLivereload(); | |
// Watch for changes in `app` folder | |
gulp.watch([ | |
'site/snippets/**/*.php', | |
'site/templates/**/*.php', | |
'assets/styles/**/*.css', | |
'assets/scripts/**/*.js', | |
'assets/images/**/*' | |
], notifyLivereload); | |
// Watch .scss files | |
gulp.watch('assets/styles/**/*.scss', ['styles']); | |
// Watch .js files | |
gulp.watch('assets/scripts/**/*.js', ['scripts']); | |
// Watch image files | |
gulp.watch('assets/images/**/*', ['images']); | |
}); | |
// Build | |
gulp.task('build', ['styles', 'images']); | |
// Default task | |
gulp.task('default', function () { | |
console.log('Start Building__') | |
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
{ | |
"name": "kirby-gulp", | |
"version": "0.0.1", | |
"description": "a gulpfile for kirby", | |
"main": "gulpfile.js", | |
"devDependencies": { | |
"jshint-stylish": "^0.1.5", | |
"tiny-lr": "0.0.5", | |
"gulp-autoprefixer": "0.0.7", | |
"gulp-sass": "^0.7.1", | |
"gulp": "^3.6.0", | |
"gulp-jshint": "^1.5.3", | |
"express": "~3.4.8", | |
"gulp-connect": "~0.3.0", | |
"connect-livereload": "~0.3.2", | |
"gulp-size": "^0.3.0", | |
"gulp-imagemin": "^0.2.0", | |
"gulp-load-plugins": "^0.5.0", | |
"gulp-cache": "^0.1.3", | |
"gulp-livereload": "^1.3.1" | |
}, | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [ | |
"gulp", | |
"kirby", | |
"ssg", | |
"staticsitegenerator", | |
"scaffolding" | |
], | |
"author": "Florenz Heldermann", | |
"license": "ISC" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment