jekyll + compass + browser-sync tasks
fs = require 'fs'
del = require 'del'
run = require 'run-sequence'
cp = require('child_process')
spawn = cp.spawn
gulp = require 'gulp'
plugins = do require 'gulp-load-plugins'
browserSync = require 'browser-sync'
dir = {
dest: '_site'
srcSass: './share/style/src'
srcCss: './share/style'
}
gulp.task 'jekyll', (done) ->
browserSync.notify '<span style="color: grey">Running:</span> $ jekyll build'
cp.spawn 'jekyll', ['build'], {stdio: 'inherit'}
.on 'close', done
gulp.task 'jekyll-rebuild', ['jekyll'], ->
browserSync.reload()
gulp.task 'browser-sync', ['css'], ->
run 'jekyll'
browserSync {
server:
baseDir: '_site'
}
# HTML Validation
gulp.task 'htmlValidate', ->
gulp.src ["./#{dir.dest}/*.html"]
.pipe plugins.htmlValidator {
format: 'json'
}
# 結果をコンソールに出力
.pipe plugins.intercept (file) ->
json = JSON.parse file.contents.toString()
errors = json.messages.filter(e, i, a) ->
return e.type != 'info'
if errors.length == 0
console.log '@@@ HTML OK! ⊂(^ω^)⊃ @@@'
else
console.log '\n\u001b[31m ???====== HTML ERROR! _(:3 」∠)_ ======???'
console.log errors
console.log ' \u001b[0m\n' + "\n"
# css: SCSSをコンパイル
gulp.task 'css', (cb) ->
# compass
gulp.src ["./#{dir.srcSass}/**/*.scss"]
.pipe plugins.compass {
project: __dirname
sass: "./#{dir.srcSass}"
css: "./#{dir.srcCss}"
}
.pipe gulp.dest "./#{dir.srcCss}"
# cleanDest
gulp.task 'cleanDest', (cb) ->
del [
"./#{dir.dest}"
], cb