-
Notifications
You must be signed in to change notification settings - Fork 18
/
gulpfile.js
executable file
·109 lines (93 loc) · 2.76 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
// gulp
var gulp = require('gulp');
// plugins
var connect = require('gulp-connect');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var minifyCSS = require('gulp-minify-css');
var clean = require('gulp-clean');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var filter = require('gulp-filter');
var mocha = require('gulp-mocha');
var exit = require('gulp-exit');
// tasks
gulp.task('lint', function() {
gulp.src(['./app/**/*.js', '!./app/assets/bower_components/**'])
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(jshint.reporter('fail'));
});
gulp.task('clean', function() {
gulp.src('dist/*')
.pipe(clean({force: true}));
gulp.src('app/bundled.js')
.pipe(clean({force: true}));
});
gulp.task('minify-css', function() {
var opts = {comments:true,spare:true};
gulp.src(['app/**/*.css', '!app/assets/bower_components/**'])
.pipe(minifyCSS(opts))
.pipe(gulp.dest('dist/assets/'))
});
gulp.task('minify-js', function() {
gulp.src(['app/**/*.js', '!app/assets/bower_components/**', '!app/bundled.js'])
.pipe(uglify())
.pipe(gulp.dest('dist/'))
});
gulp.task('copy-bower-components', function () {
gulp.src('app/assets/bower_components/**')
.pipe(gulp.dest('dist/assets/bower_components/'));
});
gulp.task('copy-bootstrap', function () {
gulp.src('node_modules/bootstrap/dist/css/bootstrap.min.css')
.pipe(gulp.dest('app/assets/css'));
gulp.src('node_modules/bootstrap/dist/js/bootstrap.min.js')
.pipe(gulp.dest('app/assets/js'));
});
gulp.task('copy-html-files', function () {
gulp.src('app/**/*.html')
.pipe(gulp.dest('dist/'));
});
gulp.task('browserify', function() {
gulp.src(['./app/app.module.js'])
.pipe(browserify({
insertGlobals: true,
debug: true
}))
.pipe(concat('bundled.js'))
.pipe(gulp.dest('./app/'))
});
gulp.task('mocha', function () {
gulp.src('app/**/*.test.js')
.pipe(mocha())
.pipe(exit());
});
gulp.task('concat', function() {
var modules = filter('**/*.module.js');
var src = filter(['**/*.js', '!**/*.module.js']);
gulp.src(['./app/**/*.js', '!./app/assets/**'])
.pipe(src)
.pipe(concat('bundle.js'))
.pipe(gulp.dest('./app/'));
});
gulp.task('connect', function () {
connect.server({
root: 'app/',
port: 8080
});
});
gulp.task('connectDist', function () {
connect.server({
root: 'dist/',
port: 9999
});
});
// default task
gulp.task('default',
['clean', 'browserify', 'connect']
);
// build task
gulp.task('build',
['lint', 'minify-css', 'minify-js', 'minify-img', 'copy-html-files', 'copy-bower-components', 'copy-bootstrap', 'connectDist']
);