-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
74 lines (62 loc) · 1.95 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
var gulp = require('gulp'),
runSequence = require('run-sequence'),
del = require('del'),
removeCode = require('gulp-remove-code'),
inlinesource = require('gulp-inline-source'),
fileinclude = require('gulp-file-include'),
rename = require('gulp-rename');
var demoMode = false;
gulp.task('clean', function () {
return del.sync(['./build/**']);
});
gulp.task('cleanDemo', function () {
demoMode = true;
return del.sync(['./build/**']);
});
gulp.task('removeMock', function () {
return gulp.src('./templates/index.tpl')
.pipe(removeCode({production: !demoMode, commentStart: '<!--', commentEnd: '-->'}))
.pipe(gulp.dest('./build/'))
});
gulp.task('inlinesource', function () {
var options = {
compress: false,
rootpath: '.'
};
var options2 = {
basepath: '.'
}
return gulp.src('./build/index.tpl')
.pipe(inlinesource(options))
.pipe(fileinclude(options2))
.pipe(gulp.dest('./build'));
});
gulp.task('rename', function () {
return gulp.src('./build/index.tpl')
.pipe(rename('index.html'))
.pipe(gulp.dest('./'));
});
gulp.task('default', function () {
runSequence('clean',
'removeMock',
'inlinesource',
'rename'
);
});
gulp.task('demo', function () {
runSequence('cleanDemo',
'removeMock',
'inlinesource',
'rename');
});
// Starts watcher. Watcher runs gulp task on changes
gulp.task('watch', function () {
gulp.watch('./src/**/*.js', ['default']);
gulp.watch('./src/**/*.html', ['default']);
gulp.watch('./templates/**/*.tpl', ['default']);
});
gulp.task('watchDemo', function () {
gulp.watch('./src/**/*.js', ['demo']);
gulp.watch('./src/**/*.html', ['demo']);
gulp.watch('./templates/**/*.tpl', ['demo']);
});