From 966c521605ed30359b462d4e10d5efaf91bf9660 Mon Sep 17 00:00:00 2001 From: Jesper Hess Nielsen Date: Fri, 8 Apr 2016 21:10:31 +0200 Subject: [PATCH] Add gulp live rebuild support --- .gitignore | 1 + .gitmodules | 3 +++ _plugins/asset_bundler | 1 + gulpfile.js | 46 ++++++++++++++++++++++++++++++++++++++++++ package.json | 6 ++++++ 5 files changed, 57 insertions(+) create mode 100644 .gitmodules create mode 160000 _plugins/asset_bundler create mode 100644 gulpfile.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 17e5238..c07cc9d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ _site/ .sass-cache/ .jekyll-metadata Gemfile.lock +node_modules/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d904f36 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "_plugins/asset_bundler"] + path = _plugins/asset_bundler + url = https://github.com/moshen/jekyll-asset_bundler.git diff --git a/_plugins/asset_bundler b/_plugins/asset_bundler new file mode 160000 index 0000000..ec2b2cd --- /dev/null +++ b/_plugins/asset_bundler @@ -0,0 +1 @@ +Subproject commit ec2b2cd8dd8d622d3ada6bb1171a1f5c187c8448 diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..0f424ab --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,46 @@ +var gulp = require('gulp'); +var browserSync = require('browser-sync'); +var cp = require('child_process'); + +var messages = { + jekyllBuild: 'Running: $ jekyll build' +}; + +/** + * Build the Jekyll Site + */ +gulp.task('jekyll-build', function (done) { + browserSync.notify(messages.jekyllBuild); + return cp.spawn('bundle.bat', ['exec','jekyll','build'], {stdio: 'inherit'}) + .on('close', done); +}); + +/** + * Rebuild Jekyll & do page reload + */ +gulp.task('jekyll-rebuild', ['jekyll-build'], function () { + browserSync.reload(); +}); + +/** + * Wait for jekyll-build, then launch the Server + */ +gulp.task('browser-sync', ['jekyll-build'], function() { + browserSync.init({ + server: '_site' + }); +}); + +/** + * Watch html/md files, run jekyll & reload BrowserSync + * if you add folder for pages, collection or datas, add them to this list + */ +gulp.task('watch', function () { + gulp.watch(['./*', '_layouts/*', '_pages/*', '_includes/*', '_posts/*', '_sass/*', 'css/*'], ['jekyll-rebuild']); +}); + +/** + * Default task, running just `gulp` will compile the sass, + * compile the jekyll site, launch BrowserSync & watch files. + */ +gulp.task('default', ['browser-sync', 'watch']); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..679551c --- /dev/null +++ b/package.json @@ -0,0 +1,6 @@ +{ + "devDependencies": { + "browser-sync": "^2.2.0", + "gulp": "^3.7" + } +} \ No newline at end of file