-
Notifications
You must be signed in to change notification settings - Fork 182
/
gulpfile.js
100 lines (85 loc) · 2.32 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
changed = require('gulp-changed'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
download = require("gulp-download"),
del = require('del'),
header = require('gulp-header'),
runSequence = require('run-sequence'),
rename = require('gulp-rename'),
browserSync = require('browser-sync'),
injector = require('gulp-injector');
var scripts = [
'src/*.js'
];
var pkg = require('./package.json'),
paths = {
remote_scripts: [
'https://raw.githubusercontent.com/jiren/JsonQuery/master/json_query.js',
],
lib: 'lib/',
scripts: [ 'lib/json_query.js'].concat(['src/main.js']),
views: ['src/views/*.html'],
dist: 'dist'
},
uncompressedJs = 'filter.js',
compressedJs = 'filter.min.js';
var banner = [
'/*',
' * <%= pkg.title || pkg.name %>',
' * <%= pkg.version %> (<%= new Date().toISOString().slice(0, 10) %>)',
' *',
' * Released under the MIT license',
' * http://opensource.org/licenses/MIT',
' *',
' * Copyright 2011-<%= new Date().getFullYear() %> <%= pkg.author.name %>[<%= pkg.author.email %>]',
' *',
' * Dependency:',
' * jQuery(v1.9 >=)',
' */',
' ',
' ' ].join('\n');
gulp.task('clean', function(cb) {
del([paths.dist], cb);
});
gulp.task('remote_scripts', function(){
var files = paths.remote_scripts;
for(var i = 0, l = files; i < l; i++){
download(files[i]).pipe(gulp.dest(paths.lib));
}
});
gulp.task('templates', function(){
return gulp.src(paths.views)
.pipe
});
gulp.task('scripts', function() {
return gulp.src(paths.scripts)
.pipe(concat(uncompressedJs))
.pipe(injector())
.pipe(header(banner, { pkg: pkg } ))
.pipe(gulp.dest(paths.dist))
.pipe(sourcemaps.init())
.pipe(uglify({output: {comments: 'all'}}))
.pipe(rename(compressedJs))
.pipe(gulp.dest(paths.dist))
});
gulp.task('watch', function() {
gulp.watch(scripts, ['scripts']);
gulp.watch(paths.lib, ['scripts']);
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./examples",
routes: {
'/dist/filter.js': './dist/filter.js'
}
}
});
});
gulp.task('build', ['clean', 'scripts'], function(cb){
});
gulp.task('default', function(cb){
runSequence('clean', 'scripts', ['browser-sync', 'watch'])
});