-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
111 lines (82 loc) · 3.22 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
110
111
'use strict'
var gulp = require('gulp');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var clean = require('gulp-clean');
var concatUtil = require('gulp-concat-util');
var _ =require('underscore');
var datejs =require('datejs');
var DEST = 'dist/';
var now = new Date();
var QUESTION_TYPES = [
'datetime',
'number',
'textarea',
'yes-no',
'single-select',
'text',
'integer',
'email',
'date',
'phonenumber',
'multi-select',
'toggle',
'autocomplete-search',
'info',
'geojson',
'numpad',
'time',
'map-multi-select'
]
gulp.copy=function(src,dest){
return gulp.src(src, {base:"."})
.pipe(gulp.dest(dest));
};
gulp.task('question-types', function() {
// Prepend the module.js file.
// js_srcs.unshift("example/app/scripts/p97-components/src/question-types/module.js");
gulp.src(DEST+'viewpoint/question-types', {read: false}).pipe(clean());
var directive_srcs = _.map(QUESTION_TYPES, function(type){
return "src/viewpoint/question-types/"+type+'/*.js';
});
// Prepend the module.js file.
directive_srcs.unshift("src/viewpoint/question-types/qt-loader.js");
console.log(directive_srcs)
gulp.src(directive_srcs)
.pipe(concat('question-types.js'))// This will output the non-minified version
.pipe(concatUtil.header('// build timestamp: '+now+'\n'))
.pipe(gulp.dest(DEST + 'viewpoint'))
.pipe(uglify())// This will output the minified version
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest(DEST + 'viewpoint'));
// Copy the Ionic HMTL templates to dist/templates
var ionic_templates_srcs = _.map(QUESTION_TYPES, function(type){
return "src/viewpoint/question-types/"+type+'/templates/**/*.html';
});
console.log(ionic_templates_srcs);
return gulp.src(ionic_templates_srcs, {base:'src/viewpoint/question-types/'})
.pipe(gulp.dest(DEST+'viewpoint/question-types'));
});
gulp.task('clean-vendor', function () {
return gulp.src('dist/vendor', {read: false})
.pipe(clean());
});
gulp.task('vendor', ['clean-vendor'], function() {
// gulp.src('dist/vendor/', {read: false}).pipe(clean())
gulp.copy(['vendor/**/*'], 'dist/')
});
gulp.task('viewpoint', function() {
gulp.src(DEST+'viewpoint/*.js', {read: false}).pipe(clean())
return gulp.src(['src/viewpoint/services/*.js'])
// This will output the non-minified version
.pipe(concat('services.js'))
.pipe(concatUtil.header('// build timestamp: '+now+'\n'))
.pipe(gulp.dest(DEST + 'viewpoint'))
// This will minify and rename to foo.min.js
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest(DEST + 'viewpoint'));
});
gulp.task('default', ['question-types', 'viewpoint', 'vendor'], function() {
});