2017-11-09 02:34:49 +00:00
|
|
|
const gulp = require('gulp');
|
|
|
|
const gutil = require('gulp-util');
|
2017-11-11 08:26:29 +00:00
|
|
|
const child = require('child_process');
|
2017-11-09 02:34:49 +00:00
|
|
|
const browserSync = require('browser-sync').create();
|
|
|
|
const siteRoot = '_site';
|
2017-11-15 04:03:47 +00:00
|
|
|
const cssFiles = 'src/style.css';
|
|
|
|
const tailwindConfig = 'tailwind-config.js';
|
2017-11-09 02:34:49 +00:00
|
|
|
|
|
|
|
gulp.task('jekyll', () => {
|
|
|
|
const jekyll = child.spawn('jekyll', ['serve',
|
|
|
|
'--watch',
|
|
|
|
'--incremental',
|
|
|
|
'--drafts'
|
|
|
|
]);
|
|
|
|
|
|
|
|
const jekyllLogger = (buffer) => {
|
|
|
|
buffer.toString()
|
|
|
|
.split(/\n/)
|
|
|
|
.forEach((message) => gutil.log('Jekyll: ' + message));
|
|
|
|
};
|
|
|
|
|
|
|
|
jekyll.stdout.on('data', jekyllLogger);
|
|
|
|
jekyll.stderr.on('data', jekyllLogger);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('css', function () {
|
|
|
|
const atimport = require('postcss-import');
|
|
|
|
const postcss = require('gulp-postcss');
|
|
|
|
const tailwindcss = require('tailwindcss');
|
|
|
|
const autoprefixer = require('gulp-autoprefixer');
|
|
|
|
const cleancss = require('gulp-clean-css');
|
|
|
|
|
2017-11-15 04:03:47 +00:00
|
|
|
return gulp.src(cssFiles)
|
2017-11-09 02:34:49 +00:00
|
|
|
.pipe(postcss([
|
|
|
|
atimport(),
|
2017-11-15 04:03:47 +00:00
|
|
|
tailwindcss(tailwindConfig)
|
2017-11-09 02:34:49 +00:00
|
|
|
]))
|
|
|
|
.pipe(autoprefixer({
|
|
|
|
browsers: ['last 2 versions'],
|
|
|
|
cascade: false
|
|
|
|
}))
|
|
|
|
.pipe(cleancss())
|
|
|
|
.pipe(gulp.dest('assets/css/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('serve', () => {
|
|
|
|
browserSync.init({
|
|
|
|
files: [siteRoot + '/**'],
|
|
|
|
port: 4000,
|
|
|
|
server: {
|
|
|
|
baseDir: siteRoot
|
|
|
|
}
|
|
|
|
});
|
2017-11-11 08:26:29 +00:00
|
|
|
|
2017-11-15 04:03:47 +00:00
|
|
|
gulp.watch([cssFiles, tailwindConfig], ['css']);
|
2017-11-09 02:34:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('default', ['css', 'jekyll', 'serve']);
|