-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (72 loc) · 2.26 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
var config = require('./gulp.config.json');
var gulp = require('gulp');
var plug = require('gulp-load-plugins')();
var mainBowerFiles = require('main-bower-files');
var stylish = require('jshint-stylish');
var server = require('karma').Server;
// remove www folder
gulp.task('clean', function () {
return gulp
.src('./www', {read: false})
.pipe(plug.clean());
});
// create project build
gulp.task('build', ['inject']);
// inject js, css into result index.html and copy it to www folder
gulp.task('inject', ['js', 'tpl', 'assets', 'css'], function () {
return gulp
.src(config.src.index)
.pipe(plug.inject(gulp.src(mainBowerFiles(), {read: false}), {name: 'bower'}))
.pipe(plug.inject(gulp.src('./www/build/*.js', {read: false})))
.pipe(plug.inject(gulp.src('./www/assets/**/*.css', {read: false})))
.pipe(gulp.dest('./www'));
});
// handle all js files and copy to www folder
gulp.task('js', ['jshint'], function () {
var task = gulp
.src(config.src.js)
.pipe(plug.ngAnnotate({
'single_quotes': true
}))
.pipe(plug.concat('all.js'));
if (config.mode === 'release') {
task
.pipe(plug.uglify())
.pipe(plug.rename('all.min.js'));
}
return task.pipe(gulp.dest('./www/build'));
});
// copy all templates to www folder
gulp.task('tpl', function () {
return gulp
.src(config.src.tpl)
.pipe(gulp.dest('./www'));
});
// handle and copy all css files into www folder
gulp.task('css', function () {
return gulp
.src(config.src.css)
.pipe(plug.concat('style.min.css'))
.pipe(plug.minifyCss('style.min.css'))
.pipe(gulp.dest('./www/assets'));
});
// copy all assets to www folder
gulp.task('assets', function () {
return gulp
.src([config.src.assets, '!' + config.src.css])
.pipe(gulp.dest('./www/assets'));
});
// check jsHing rules over js files
gulp.task('jshint', function () {
return gulp
.src(config.src.js)
.pipe(plug.jshint())
.pipe(plug.jshint.reporter(stylish));
});
// run unit tests
gulp.task('unit-test', function (done) {
new server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});