-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.babel.js
94 lines (78 loc) · 2.41 KB
/
gulpfile.babel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import child from 'child_process';
import {create as bsCreate} from 'browser-sync';
const browserSync = bsCreate();
import gulp from 'gulp';
import PluginError from 'plugin-error';
import log from 'fancy-log';
import runSeq from 'run-sequence';
import sass from 'gulp-sass';
import webpack from 'webpack';
import yargs from 'yargs';
import uglifycss from 'gulp-uglifycss';
const siteRoot = '_site';
const cssFiles = 'scss/app.scss';
gulp.task('css', () => {
let pipe = gulp.src(cssFiles)
.pipe(sass({
"includePaths": [
'./node_modules/foundation-sites/scss',
'./node_modules/normalize-scss/sass'
]
}))
.on('error', log);
if (yargs.argv.production) {
pipe = pipe.pipe(uglifycss({
"uglyComments": true
}));
}
return pipe.pipe(gulp.dest('css'));
});
gulp.task("webpack", (cb) => {
return webpack(require("./webpack.config.js")).run((err, stats) => {
if (err) { throw new PluginError('webpack-build', err); }
log('[webpack-build]', stats.toString({
colors: true
}));
cb();
});
});
gulp.task('jekyll', () => {
const jekyll = child.spawn('bundler', ['exec', 'jekyll', 'build', '--incremental', '--watch']);
const jekyllLogger = (buffer) => {
buffer.toString()
.split(/\n/)
.forEach((message) => log('Jekyll: ' + message));
};
jekyll.stdout.on('data', jekyllLogger);
jekyll.stderr.on('data', jekyllLogger);
});
gulp.task('jekyll-build', () => {
let jekyll;
if (yargs.argv.production) {
log("Hello!");
jekyll = child.spawn('jekyll', ['build']);
} else {
jekyll = child.spawn('bundler', ['exec', 'jekyll', 'build']);
}
const jekyllLogger = (buffer) => {
buffer.toString()
.split(/\n/)
.forEach((message) => log('Jekyll: ' + message));
};
jekyll.stdout.on('data', jekyllLogger);
jekyll.stderr.on('data', jekyllLogger);
return jekyll;
});
gulp.task('serve', () => {
browserSync.init({
files: [siteRoot + '/**'],
port: 4000,
server: {
baseDir: siteRoot
}
});
gulp.watch('scss/*.scss', ['css']);
gulp.watch('js-src/*.*', ['webpack']);
});
gulp.task('default', gulp.parallel('css', 'webpack', 'jekyll', 'serve'));
gulp.task('build', gulp.series(['css', 'webpack', 'jekyll-build']));