55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
const gulp = require('gulp');
|
|
const child = require('child_process');
|
|
const gutil = require('gulp-util');
|
|
const browserSync = require('browser-sync').create();
|
|
const siteRoot = '_site';
|
|
|
|
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('src/style.css')
|
|
.pipe(postcss([
|
|
atimport(),
|
|
tailwindcss('tailwind-config.js')
|
|
]))
|
|
.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.task('default', ['css', 'jekyll', 'serve']); |