forked from duguncom/dugun-forms
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
64 lines (52 loc) · 1.77 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
var gulp = require('gulp'),
gulpConcat = require('gulp-concat'),
angularFilesort = require('gulp-angular-filesort'),
ngHtml2Js = require('gulp-ng-html2js'),
htmlmin = require('gulp-htmlmin'),
htmlhint = require('gulp-htmlhint'),
clean = require('gulp-clean'),
pipes = {},
KarmaServer = require('karma').Server;
pipes.buildJS = function() {
console.info('Building JS');
var source = ['src/**/*.js', '!**/*.spec.js'];
return gulp.src(source)
.pipe(angularFilesort())
.pipe(gulpConcat('dugun-forms.js'))
.pipe(gulp.dest('dist/'));
};
pipes.buildHTML = function() {
return pipes.htmlSources()
.pipe(htmlhint({'doctype-first': false}))
.pipe(htmlhint.reporter())
.pipe(htmlmin({collapseWhitespace: true, removeComments: true}))
.pipe(ngHtml2Js({
moduleName: "dugun.forms",
declareModule: false
}))
.pipe(gulpConcat('templates.js'))
.pipe(gulp.dest('dist/'));
};
pipes.htmlSources = function() {
console.info('Building HTML');
var source = ['src/**/*.html'];
return gulp.src(source);
};
pipes.build = function() {
console.info('Building');
return gulp.src(['dist/dugun-forms.js', 'dist/templates.js'])
.pipe(clean({force: true}))
.pipe(gulpConcat('main.js'))
.pipe(gulp.dest('dist/'))
.pipe(gulp.src(['dist/dugun-forms.js', 'dist/templates.js'], {read: false}));
};
pipes.test = function(done) {
new KarmaServer({
configFile: __dirname + '/karma.conf.js',
}, done).start();
}
gulp.task('build-js', pipes.buildJS);
gulp.task('merge-js', pipes.mergeJS);
gulp.task('build-html', pipes.buildHTML);
gulp.task('build', ['build-js', 'build-html'], pipes.build);
gulp.task('test', pipes.test);