forked from DaHaiz/ngFlowchart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
107 lines (89 loc) · 2.69 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
'use strict';
var gulp = require('gulp'),
concat = require('gulp-concat'),
merge2 = require('merge2'),
del = require('del'),
open = require('gulp-open'),
connect = require('gulp-connect'),
ngAnnotate = require('gulp-ng-annotate'),
ngFilesort = require('gulp-angular-filesort'),
ngHtml2Js = require('gulp-ng-html2js'),
bowerFiles = require('main-bower-files'),
karma = require('karma').server;
//postcss = require('gulp-postcss'),
//sourcemaps = require('gulp-sourcemaps'),
//autoprefixer = require('autoprefixer-core');
var safeReload = 0; // Semaphore for the reload task, should not run at same time as build tasks. If 0 it is save to run reload.
var jsFilter = {
filter: /\.js$/i
};
gulp.task('vendorScripts', function() {
safeReload++;
var ret = gulp.src(bowerFiles(jsFilter))
.pipe(concat('vendor.js'))
.pipe(gulp.dest('dist/'));
safeReload--;
return ret;
});
gulp.task('flowchartScripts', function() {
safeReload++;
var ret = merge2(
gulp.src(['app/flowchart/*.js', 'app/bower_components/bind-polyfill/index.js', '!app/flowchart/*_test.js'])
.pipe(ngAnnotate())
.pipe(ngFilesort()),
gulp.src('app/flowchart/*.html')
.pipe(ngHtml2Js({
moduleName: 'flowchart-templates',
prefix: 'flowchart/'
}))
)
.pipe(concat('ngFlowchart.js'))
.pipe(gulp.dest('dist'));
safeReload--;
return ret;
});
gulp.task('connect', ['build'], function() {
connect.server({
root: ['dist'],
port: 8000,
livereload: true
});
});
gulp.task('open', function() {
var options = {
url: 'http://localhost:' + 8000
};
gulp.src('dist/index.html')
.pipe(open('', options));
});
gulp.task('watch', function() {
gulp.watch('app/flowchart/flowchart.css', ['flowchartCss']);
gulp.watch(['app/flowchart/*.js', '!app/flowchart/*_test.js', 'app/flowchart/*.html'], ['flowchartScripts']);
gulp.watch('dist/**', ['reload']);
});
gulp.task('reload', function() {
if (safeReload === 0) {
return gulp.src('dist/**')
.pipe(connect.reload());
}
});
gulp.task('flowchartCss', function() {
gulp.src('app/flowchart/flowchart.css')
.pipe(gulp.dest('dist'));
//gulp.src('dist/onedatastyle.css')
// .pipe(postcss([autoprefixer({ browsers: ['last 2 version'] }) ]))
// .pipe(gulp.dest('dist/compiled/'))
});
gulp.task('test', function(done) {
karma.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, function() {
done();
});
});
gulp.task('clean', function(done) {
del(['dist/ngFlowchart.js', 'dist/vendor.js', 'dist/flowchart.css'], done);
});
gulp.task('build', ['flowchartScripts', 'flowchartCss', 'vendorScripts']);
gulp.task('default', ['connect', 'open', 'watch']);