-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
110 lines (84 loc) · 2.18 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
101
102
103
104
105
106
107
108
109
var gulp = require('gulp'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify')
var karma = require('karma')
//var browserSync = require('browser-sync')
var connect = require('gulp-connect')
var livereload = require('gulp-livereload')
// 路径配置
var paths = {
scripts: [
'src/_sea-debug.js',
'src/_intro.js',
'src/main.js',
'src/_fix.js',
'src/prototype.js',
'src/lang.js',
'src/data.js',
'src/http.js',
'src/node.js',
'src/event.js',
'src/module.js',
'src/css.js',
'src/attr.js',
'src/route.js',
'src/animate.js',
'src/extend.js',
'src/_outro.js'
],
images: ''
}
gulp.task('connect', ['minify'], function() {
connect.server({
root: '',
livereload: true
})
})
// Lint JS
gulp.task('lint', ['minify'], function() {
return gulp.src('dist/fishbone.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
})
// Concat & Minify JS
gulp.task('minify', function() {
return gulp.src(paths.scripts)
.pipe(concat('fishbone.js'))
.pipe(gulp.dest('dist'))
.pipe(rename('fishbone.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'))
.pipe(livereload())
});
gulp.task('html', function() {
livereload.reload()
})
gulp.task('script', function() {
livereload.reload()
})
// Watch Our Files
gulp.task('watch', function() {
var server = livereload({ start: true })
livereload.listen()
gulp.watch('*.html', ['html'], function(file) {
server.changed(file.path)
server.reload()
})
gulp.watch('src/*.js', ['lint', 'minify', 'script'], function(file) {
server.changed(file.path)
})
})
// karma test
gulp.task('karma', function() {
karma.server.start({
configFile: process.cwd() + '/karma.conf.js',
singleRun: true
}, done)
})
// Default
//gulp.task('default', ['lint', 'minify', 'watch', 'browser-sync'])
gulp.task('default', ['minify', 'watch', 'connect'])
gulp.task('package', ['minify'])
gulp.task('test', ['lint'])