forked from mozilla/protocol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·71 lines (61 loc) · 1.48 KB
/
gulpfile.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
'use strict';
const drizzle = require('drizzle-builder');
const gulp = require('gulp');
const ghPages = require('gulp-gh-pages');
const helpers = require('@cloudfour/hbs-helpers');
const tasks = require('@cloudfour/gulp-tasks');
const env = require('gulp-util').env;
const config = require('./config');
const sass = require('gulp-sass');
// Append config
Object.assign(config.drizzle, { helpers });
// Register core tasks
[
'clean',
'copy',
'js',
'serve',
'watch'
].forEach(name => tasks[name](gulp, config[name]));
// Register Drizzle builder task
gulp.task('drizzle', () => {
const result = drizzle(config.drizzle);
return result;
});
// Register Sass preprocessor
gulp.task('sass', () => {
return gulp.src('./src/assets/sass/**/*.scss')
.pipe(sass({ style: 'compact' }))
.pipe(gulp.dest('./dist/assets/css'));
});
// Register frontend composite task
gulp.task('frontend', [
'drizzle',
'copy',
'sass',
'js'
]);
// Register build task (for continuous deployment via Netflify)
gulp.task('build', ['clean'], done => {
gulp.start('frontend');
done();
});
/**
* Register demo task (deploy output to GitHub Pages)
* NOTE: Run this after building.
*/
gulp.task('demo', () => {
const buildDest = `${config.drizzle.dest.pages}/**/*`;
return gulp.src(buildDest)
.pipe(ghPages({
cacheDir: 'demo'
}));
});
// Register default task
gulp.task('default', ['frontend'], done => {
gulp.start('serve');
if (env.dev) {
gulp.start('watch');
}
done();
});