vac.dev-experimental-old/gulpfile.js

59 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-11-09 02:34:49 +00:00
const gulp = require('gulp');
const gutil = require('gulp-util');
const child = require('child_process');
2017-11-09 02:34:49 +00:00
const browserSync = require('browser-sync').create();
const siteRoot = '_site';
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');
return gulp.src(cssFiles)
2017-11-09 02:34:49 +00:00
.pipe(postcss([
atimport(),
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
}
});
gulp.watch([cssFiles, tailwindConfig], ['css']);
2017-11-09 02:34:49 +00:00
});
gulp.task('default', ['css', 'jekyll', 'serve']);