-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
61 lines (55 loc) · 1.79 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
var gulp = require('gulp');
var path = require('path');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var watch = require('gulp-nuiwatch');
var nui = require('gulp-nui');
var nunjucks = require('gulp-nunjucks-render');
gulp.task('concat', function() {
return gulp.src(['./src/nui.js',
'./src/util.js',
'./src/template.js',
'./src/events.js',
'./src/component.js'
])
.pipe(concat('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:'./assets/script/config.js',
filterPath: function(src) {
return src.replace(/^\/nui\//, this.paths.base)
}
}
gulp.task('nunjucks', function() {
return gulp.src('./html/**/*.html')
.pipe(nunjucks({
path: './tpl'
}))
.pipe(nui(options))
.pipe(gulp.dest('./'))
});
gulp.task('watch', function() {
watch(['./src/components/**/*.js', './pages/**/*', '!./pages/**/*.html', './dist/*.js', './assets/**/*', '!./assets/script/config.js', , '!./**/*.map', '!./**/*-{debug,min}.{js,css}'],
function(watcher) {
options.watcher = watcher;
gulp.src(['./pages/**/*.html'])
.pipe(nui(options))
.pipe(gulp.dest('./pages'))
gulp.src(['./index.html'])
.pipe(nui(options))
.pipe(gulp.dest('./'))
})
gulp.watch(['./src/*.js'], ['concat']);
gulp.watch(['./html/**/*.html', './tpl/*.tpl'], ['nunjucks']);
});
gulp.task('default', ['concat', 'nunjucks', 'watch']);