-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
133 lines (119 loc) · 3.56 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* Comentanto funciones usando estilo JSDoc http://usejsdoc.org/
* gulp - Automatizador flujo de trabajo en el front-End
* webserver - https://www.npmjs.com/package/gulp-webserver
*/
var gulp = require('gulp')
var webserver = require('gulp-webserver')
var minify = require('gulp-minifier')
//var babel = require('gulp-babel')
//var merge = require('merge-stream')
const tar = require('gulp-tar')
const gzip = require('gulp-gzip')
var rm = require('gulp-rm')
var jshint = require('gulp-jshint')
const jshintConfig = require('./jshitn.conf.json')
var webserverConfig = {
host: 'localhost',
port: 3000,
livereload: true,
directoryListing: false,
open: true,
proxies: [{
source: '/geoserver',
target: 'http://sig.udistrital.edu.co:8080/geoserver',
options: {
headers: {
'DEVELOPER': 'juusechec'
}
}
},{
source: '/proxy',
target: 'http://localhost:12345/',
options: {
headers: {
'WebSite': 'https://github.com/juusechec/goresource-proxy'
}
}
}]
};
gulp.task('webserver', function() {
gulp.src('app').pipe(webserver(webserverConfig))
})
gulp.task('webserver:dist', function() {
gulp.src('dist/app').pipe(webserver(webserverConfig))
})
/*
// https://www.youtube.com/watch?v=TGiBG6II6Jk
gulp.task('watch', ['sass'], function (){
gulp.watch('./sass/**\/*.css', ['sass'])
});
*/
gulp.task('minify', function() {
var allfiles = gulp.src(['app/**/*']).pipe(minify({
minify: true,
collapseWhitespace: true,
conservativeCollapse: true,
minifyJS: true,
minifyCSS: true,
getKeptComment: function(content, filePath) {
var m = content.match(/\/\*![\s\S]*?\*\//img)
return m && m.join('\n') + '\n' || ''
}
})).pipe(gulp.dest('dist/app'))
// http://stackoverflow.com/questions/34398338/uglification-failed-unexpected-character
// var jsfiles = gulp.src(['app/**/*.js', '!app/vendor/**/*', '!app/js/mustache-dojo.js'])
// .pipe(babel({
// presets: ['es2015']
// }))
// .pipe(minify({
// minify: true,
// collapseWhitespace: true,
// conservativeCollapse: true,
// minifyJS: true,
// minifyCSS: true,
// getKeptComment: function(content, filePath) {
// var m = content.match(/\/\*![\s\S]*?\*\//img);
// return m && m.join('\n') + '\n' || '';
// }
// }))
// .pipe(gulp.dest('dist/app'))
// var vendorfiles = gulp.src(['app/vendor/**/*'])
// .pipe(gulp.dest('dist/app/vendor'))
// var exeptionfiles = gulp.src(['app/js/mustache-dojo.js'])
// .pipe(gulp.dest('dist/app/js'))
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md
//return merge(allfiles, vendorfiles)
return allfiles
})
gulp.task('pack', () =>
gulp.src('dist/app/**/*')
.pipe(tar('pack.tar'))
.pipe(gzip())
.pipe(gulp.dest('build'))
)
gulp.task('clean', ['clean:dist', 'clean:build'], function() {
// place code for your default task here
})
gulp.task('clean:dist', function() {
return gulp.src('dist/**/*', {
read: false
})
.pipe(rm())
})
gulp.task('clean:build', function() {
return gulp.src('build/**/*', {
read: false
})
.pipe(rm())
})
// configure the jshint task
gulp.task('jshint', function() {
return gulp.src(['app/**/*.js', '!app/lib/**/*'])
.pipe(jshint(jshintConfig))
.pipe(jshint.reporter('default'))
})
//https://github.com/andresvia/go-angular-drone/blob/master/.drone.yml
gulp.task('default', ['webserver'], function() {
// place code for your default task here
})