forked from madbook/reddit-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (66 loc) · 1.79 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
72
73
74
75
76
77
'use strict';
require('babel-register')({
ignore: false,
only: /.+(?:(?:\.es6\.js)|(?:.jsx))$/,
extensions: ['.js', '.es6.js', '.jsx' ],
sourceMap: true,
presets: [
'es2015',
'react',
],
plugins: [
'transform-object-rest-spread',
'transform-async-to-generator',
'transform-class-properties',
'syntax-trailing-function-commas',
],
});
var glob = require('glob');
var gulp = require('gulp');
var gutil = require('gulp-util');
var sequence = require('gulp-sequence').use(gulp);
var util = require('util');
// Check node version
require('./version');
var options = {
debug: true,
watch: false,
paths: {
build: './build',
js: 'js',
css: 'css',
},
};
gulp.task('load-tasks', function() {
glob.sync('./buildTasks/*.js').forEach(function(file) {
try {
var task = require(file);
gutil.log(util.format('loading task: %s', file));
task(gulp, options);
} catch (e) {
gutil.log(util.format('unable to require task: %s\n\n%s', file, e));
}
});
});
gulp.task('set-watch', function() {
options.watch = true;
});
gulp.task('set-prod', function() {
options.debug = false;
});
gulp.task('load-prod', sequence('set-prod', 'load-tasks'));
gulp.task('load-dev', sequence('load-tasks'));
gulp.task('load-watch', sequence('set-watch', 'load-tasks', 'watcher'));
gulp.task('build', sequence('clean', 'assets', ['js', 'less']));
gulp.task('default', sequence('load-prod', 'build'));
gulp.task('dev', sequence('load-dev', 'build'));
gulp.task('watch', sequence('load-watch', 'build'));
gulp.task('icon-fonts', sequence('set-prod', 'load-tasks', 'icons'));
// gulp seems to hang after finishing in some environments
gulp.on('stop', function() {
if (!options.watch) {
process.nextTick(function() {
process.exit(0);
});
}
});