Merge pull request #2 from phproberto/gulp-improvements

Gulp fixes/improvements
This commit is contained in:
Taylor Bryant 2017-11-15 18:45:22 -06:00 committed by GitHub
commit 9852edc330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 16 deletions

View File

@ -8,3 +8,4 @@ exclude:
- package-lock.json - package-lock.json
- Gemfile - Gemfile
- Gemfile.lock - Gemfile.lock
- src

View File

@ -6,23 +6,27 @@ const siteRoot = '_site';
const cssFiles = 'src/style.css'; const cssFiles = 'src/style.css';
const tailwindConfig = 'tailwind-config.js'; const tailwindConfig = 'tailwind-config.js';
gulp.task('jekyll', () => { var jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
const jekyll = child.spawn('jekyll', ['serve',
'--watch',
'--incremental',
'--drafts'
]);
const jekyllLogger = (buffer) => { /**
buffer.toString() * Build the Jekyll Site
.split(/\n/) */
.forEach((message) => gutil.log('Jekyll: ' + message)); gulp.task('jekyll-build', function (done) {
}; browserSync.notify('Running: $ jekyll build');
return child.spawn( jekyll , ['build'], {stdio: 'inherit'})
jekyll.stdout.on('data', jekyllLogger); .on('close', done);
jekyll.stderr.on('data', jekyllLogger);
}); });
/**
* Rebuild Jekyll & do page reload
*/
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
/**
* Compile styles
*/
gulp.task('css', function () { gulp.task('css', function () {
const atimport = require('postcss-import'); const atimport = require('postcss-import');
const postcss = require('gulp-postcss'); const postcss = require('gulp-postcss');
@ -40,10 +44,14 @@ gulp.task('css', function () {
cascade: false cascade: false
})) }))
.pipe(cleancss()) .pipe(cleancss())
.pipe(gulp.dest('_site/assets/css/'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('assets/css/')); .pipe(gulp.dest('assets/css/'));
}); });
/**
* Serve site with browserSync
*/
gulp.task('serve', () => { gulp.task('serve', () => {
browserSync.init({ browserSync.init({
files: [siteRoot + '/**'], files: [siteRoot + '/**'],
@ -54,6 +62,7 @@ gulp.task('serve', () => {
}); });
gulp.watch([cssFiles, tailwindConfig], ['css']); gulp.watch([cssFiles, tailwindConfig], ['css']);
gulp.watch(['**/*.html', '**/*.yml', '!_site/**/*'], ['jekyll-rebuild']);
}); });
gulp.task('default', ['css', 'jekyll', 'serve']); gulp.task('default', ['css', 'serve']);