-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
141 lines (126 loc) · 4.17 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
const del = require("del");
var sourcemaps = require('gulp-sourcemaps');
var gulp = require('gulp');
var babel = require('gulp-babel');
var sass = require('gulp-sass');
var jade = require('gulp-jade');
var gzip = require('gulp-gzip');
var uglify = require('gulp-uglify');
var pump = require('pump');
var runSequence = require('run-sequence');
var newer = require('gulp-newer');
var merge = require('merge-stream');
var sourcemaps = require('gulp-sourcemaps');
function clean() {
return del(['./dist/']);
}
gulp.task('sass', function() {
return gulp.src('src/sass/csvstore.sass')
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: env === 'production' ? 'compressed' : '' }).on('error', sass.logError))
.pipe(sourcemaps.write('.'))
//.pipe(gzip())
.pipe(gulp.dest('dist/css'));
});
gulp.task('templates', function() {
return gulp.src('src/templates/*.jade')
.pipe(jade({
locals: {}
}))
.pipe(gzip())
.pipe(gulp.dest('dist/html'))
});
gulp.task('fonts', function() {
return gulp.src([
'src/fonts/*.ttf',
'node_modules/font-awesome/fonts/*.*'
])
.pipe(gzip())
.pipe(gulp.dest('dist/fonts'));
});
gulp.task('lit-html', function(cb) {
return pump([
gulp.src([
'node_modules/lit-html/*.js',
'node_modules/lit-html/polyfills/*.js',
'node_modules/lit-html/directives/*.js',
'node_modules/lit-html/lib/*.js'
], {
base: 'node_modules'
}),
gzip(),
gulp.dest('dist/js/')
], function(err) {
console.log('Task lit-html finished! ', err || 'No errors.');
});
});
gulp.task('client-js', function(cb) {
return pump([
gulp.src([
'node_modules/jquery/dist/jquery.js',
'node_modules/signals/dist/signals.js',
'node_modules/hasher/dist/js/hasher.js',
'node_modules/crossroads/dist/crossroads.js',
'src/js/*.js'
]),
//sourcemaps.init(),
//uglify(),
//sourcemaps.write('.'),
gzip(),
gulp.dest('dist/js/')
], function(err) {
console.log('Task client-js finished! ', err || 'No errors.');
});
});
gulp.task('copy', function(cb) {
return pump([
gulp.src(['src/lib/scrapers/*.js']),
gulp.dest('dist/lib/scrapers')
]);
});
gulp.task('babel', function() {
var server = gulp.src(['src/server.js'])
.pipe(newer('dist'))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ["es2015", "stage-0"]
}))
.pipe(sourcemaps.write('dist'))
.pipe(gulp.dest('dist'));
var parsers = gulp.src(['src/lib/parsers/*.js'])
.pipe(newer('dist/lib/parsers'))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ["es2015", "stage-0"]
}))
.pipe(sourcemaps.write('dist/lib/parsers'))
.pipe(gulp.dest('dist/lib/parsers'));
var scrapers = gulp.src(['src/lib/scrapers/*.js'])
.pipe(newer('dist/lib/scrapers'))
.pipe(sourcemaps.init())
.pipe(babel({
presets: ["es2015", "stage-0"]
}))
.pipe(sourcemaps.write('dist/lib/scrapers'))
.pipe(gulp.dest('dist/lib/scrapers'));
return merge(server, parsers, scrapers);
});
gulp.task('watch', function(cb) {
gulp.watch(['src/sass/csvstore.sass'], gulp.series('sass'));
gulp.watch(['src/templates/*.jade'], gulp.series('templates'));
gulp.watch(['src/js/*.js'], gulp.series('client-js'));
gulp.watch(['src/server.js', 'src/lib/parsers/*'], gulp.series('babel'));
gulp.watch(['src/lib/scrapers/*'], gulp.series('copy'));
});
gulp.task('set-production', function(cb) {
env = 'production';
cb();
});
gulp.task('set-development', function(cb) {
env = 'development';
cb();
});
gulp.task('build', gulp.series('set-production', clean, 'sass', 'templates', 'fonts', 'client-js', 'babel', 'copy'));
gulp.task('devbuild', gulp.series('set-development', clean, 'sass', 'templates', 'fonts', 'client-js', 'lit-html', 'babel', 'copy'));
gulp.task('default', gulp.series('build'));
gulp.task('dev', gulp.series('devbuild', 'watch'));