forked from homkai/HyMobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
48 lines (41 loc) · 1.3 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
var Gulp = require('gulp');
var Jsx = require('gulp-react');
var Rename = require('gulp-rename');
var HyMobileWrapper = require('gulp-hymobile-wrapper');
var Dot = require('gulp-seajs-dot');
var CSS = require('gulp-seajs-css');
Gulp.task('css', function() {
return Gulp.src('./style/**/*.css')
.pipe(CSS({prefix: 'css_'}))
.pipe(Rename(function(path){
path.basename = 'css_'+path.basename;
}))
.pipe(Gulp.dest('./app/'));
});
Gulp.task('style', ['css']);
// doT模板
Gulp.task('dot', function() {
return Gulp.src('./tpl/**/*.html')
.pipe(Dot({prefix: 'tpl_'}))
.pipe(Rename(function(path){
path.basename = 'tpl_'+path.basename;
}))
.pipe(Gulp.dest('./app/'));
});
// React模板
Gulp.task('jsx', function () {
return Gulp.src('./tpl/**/*.jsx')
.pipe(Jsx())
.pipe(HyMobileWrapper({prefix: 'tpl_', isModule: true}))
.pipe(Rename(function(path){
path.basename = 'tpl_'+path.basename;
}))
.pipe(Gulp.dest('./app/'));
});
Gulp.task('tpl', ['dot', 'jsx']);
Gulp.task('watch', function(){
Gulp.watch('./tpl/**/*.jsx', ['jsx']);
Gulp.watch('./tpl/**/*.html', ['html']);
Gulp.watch('./style/**/*.css', ['css']);
});
Gulp.task('default', ['tpl', 'style', 'watch']);