forked from yinjiazeng/nui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
79 lines (70 loc) · 2.23 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
var gulp = require('gulp');
var path = require('path');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var nui = require('gulp-nui');
var nunjucks = require('gulp-nunjucks-render');
var babel = require('babel-core');
gulp.task('concat', function() {
gulp.src(['./src/load.js'])
.pipe(rename('nui-load.js'))
.pipe(gulp.dest('./dist/'))
.pipe(uglify({
mangle: true,
output: {
keep_quoted_props: true
}
}))
.pipe(rename('nui-load-min.js'))
.pipe(gulp.dest('./dist/'))
//打包所有模块
// gulp.src(['./src/load.js'])
// .pipe(rename('nui.js'))
// .pipe(gulp.dest('./dist/'))
// .pipe(uglify({
// mangle: true,
// output: {
// keep_quoted_props: true
// }
// }))
// .pipe(rename('nui-min.js'))
// .pipe(gulp.dest('./dist/'))
});
var options = {
url:'./config.js',
jsmin:null,
cssmin:null,
syncAsset:'node',
filterPath: function(src) {
return src.replace(/^\/nui\//, this.paths.base)
}
}
gulp.task('nunjucks', function() {
return gulp.src('./html/**/*.html')
.pipe(nunjucks({
path: ['./tpl', './html']
}))
.pipe(gulp.dest('./'))
});
gulp.task('revhtml', ['nunjucks'], function(){
gulp.src(['./pages/**/*.html'])
.pipe(nui(options))
.pipe(gulp.dest('./pages'))
gulp.src(['./index.html'])
.pipe(nui(options))
.pipe(gulp.dest('./'))
})
gulp.task('revcss', function(){
gulp.src(['./{pages,assets,src}/**/*.{css,less}'])
.pipe(nui())
.pipe(gulp.dest('./'))
})
gulp.task('watch', function() {
gulp.watch(['{pages,assets}/**/*.{js,css,less}', '!{pages,assets}/**/*-min.{js,css}','!assets/script/config.js'], ['revhtml']);
gulp.watch(['{pages,assets}/**/*.{jpg,png,gif,eot,svg,ttf,woff}'], ['revcss']);
gulp.watch(['src/**/*.{js,css,less}'], ['concat', 'revhtml']);
gulp.watch(['html/**/*.html', 'tpl/*.tpl'], ['nunjucks', 'revhtml']);
gulp.watch(['src/**/*'], ['concat', 'revhtml']);
});
gulp.task('default', ['concat', 'revhtml', 'revcss', 'watch']);