-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
104 lines (93 loc) · 2.67 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
var gulp = require('gulp'),
livereload = require('gulp-livereload'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
gutil = require('gulp-util'),
ngAnnotate = require('gulp-ng-annotate'),
beep = require('beepbeep'),
header = require('gulp-header'),
wrap = require("gulp-wrap"),
sass = require('gulp-sass'),
jade = require('gulp-jade'),
minifycss = require('gulp-minify-css'),
autoprefixer = require('gulp-autoprefixer'),
plumber = require('gulp-plumber');
karma = require('karma').server,
package = require('./package.json');
var dirs = {
js: {
src: './source/js',
dest: './build/js'
},
demo: {
src: './source/demo',
dest: './demo'
},
test: {
src: './source/js',
dest: './karma'
}
};
var jsHeader = [
'// Nicholas Johnson (www.nicholasjohnson.com)',
'// Forward Advance Training (www.forwardadvance.com)',
'// MIT licence'
].join('\n');
gulp.task('js', function () {
return gulp.src([dirs.js.src, '*.js'].join('/'))
.pipe(wrap('(function() {\n<%= contents %>\n})();'))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.on('error', beep)
.pipe(concat(package.name + '.js'))
.pipe(ngAnnotate())
.on('error', gutil.noop)
.pipe(header(jsHeader + '\n\n'))
.pipe(gulp.dest(dirs.js.dest))
.pipe(rename(package.name + '.min.js'))
.pipe(uglify())
.on('error', gutil.noop)
.pipe(header(jsHeader + '\n\n'))
.pipe(gulp.dest(dirs.js.dest))
.pipe(livereload());
});
gulp.task('test', function (done) {
karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done);
});
gulp.task('tdd', function (done) {
karma.start({
configFile: __dirname + '/karma.conf.js'
}, done);
});
gulp.task('demo:jade', function() {
return gulp.src([dirs.demo.src, '**', '*.jade'].join('/'))
.pipe(jade({basedir: __dirname, pretty:true}))
.on('error', gutil.log)
.pipe(gulp.dest(dirs.demo.dest));
})
gulp.task('demo:js', function() {
return gulp.src([dirs.demo.src, '**', '*.js'].join('/'))
.pipe(gulp.dest(dirs.demo.dest));
})
gulp.task('demo:sass', function() {
return gulp.src([dirs.demo.src, '**', '*.scss'].join('/'))
.pipe(sass({ style: 'expanded' }))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.on('error', gutil.log)
.pipe(gulp.dest(dirs.demo.dest));
})
gulp.task('demo', ['demo:jade', 'demo:js', 'demo:sass']);
gulp.task('watch', function() {
gulp.watch([dirs.js.src, '*.js'].join('/'), ['js']);
gulp.watch([dirs.demo.src, '**', '*'].join('/'), ['demo']);
});
gulp.task('default', [
'js',
'tdd',
'watch'
]);