-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
65 lines (56 loc) · 2 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
var gulp = require('gulp'),
guglify = require('gulp-uglify'),
ggzip = require('gulp-gzip'),
gpages = require('gulp-gh-pages'),
gutil = require('gulp-util'),
gconcat = require('gulp-concat'),
gtemplate = require('gulp-template'),
grename = require('gulp-rename'),
gdata = require('gulp-data'),
stringEscape = require('js-string-escape'),
fs = require('fs');
gulp.task('min', function() {
return gulp.src('./src/murk.js')
.on('error', gutil.log)
.pipe(gulp.dest('./examples/js'))
.pipe(guglify())
.pipe(gulp.dest('./dist'));
});
gulp.task('zip', function() {
return gulp.src('./dist/murk.js')
.on('error', gutil.log)
.pipe(ggzip())
.pipe(gulp.dest('./dist'));
});
gulp.task('examples', function() {
return gulp.src([
'./examples/build/js/example.js',
'./examples/build/js/basic-example.js',
'./examples/build/js/repeat-example.js'
])
.on('error', gutil.log)
.pipe(gconcat('examples.min.js'))
.pipe(guglify())
.pipe(gulp.dest('./examples/js'));
});
gulp.task('template', ['examples'], function() {
var templateFiles = {
basicJs: fs.readFileSync('./examples/build/js/basic-example.js').toString(),
repeatJs: fs.readFileSync('./examples/build/js/repeat-example.js').toString(),
basicTmpl: fs.readFileSync('./examples/build/templates/basic-example.tmpl').toString(),
repeatTmpl: fs.readFileSync('./examples/build/templates/repeat-example.tmpl').toString()
};
return gulp.src('./examples/build/templates/layout.tmpl')
.on('error', gutil.log)
.pipe(gtemplate({ data: templateFiles }))
.pipe(grename('./index.html'))
.pipe(gulp.dest('./examples'));
});
gulp.task('gh', function() {
return gulp.src('./examples/**/*')
.pipe(gpages());
});
gulp.task('watch', function() {
gulp.watch(['./src/**/*','./examples/**/*', './gulpfile.js'], ['min', 'zip', 'template']);
});
gulp.task('default', ['min', 'zip', 'template', 'watch']);