forked from xcash/bootstrap-autocomplete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
114 lines (97 loc) · 2.58 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
'use strict';
var gulp = require('gulp'),
log = require('fancy-log'),
colors = require('ansi-colors'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
plumber = require('gulp-plumber'),
size = require('gulp-size'),
rename = require('gulp-rename'),
webpack = require('webpack-stream'),
browserSync = require('browser-sync');
var reload = browserSync.reload;
gulp.task('default',
function () {
log('\n'+
colors.green('GULP TASKS') + '\n\t' +
// default | help
colors.yellow('default | help') + '\n\t\t' +
'Shows the available tasks\n\n\t' +
// monitor
colors.yellow('monitor') + '\n\t\t' +
'Real time check for changes in js files.\n\t\tIt handles errors and rebuilds the minified and compiled files.\n\n\t' +
// release
colors.yellow('release') + '\n\t\t' +
'Rebuild and concatenate all js files.\n\t\tMinifies and uglifies JS for deploy.\n\t\t'
);
}
);
gulp.task('monitor', function () {
gulp.series('build-js', function(done) {
done();
gulp.parallel('watch', 'dev-server', function(done) {
done();
})();
})();
});
gulp.task('release', function () {
gulp.series('build-js', 'dist-min', function(done) {
done();
})();
});
gulp.task('watch', function () {
gulp.watch('src/**/*', gulp.series('build-js', function (done) {
reload();
done();
}));
});
gulp.task('build-js', function () {
// copy index.html
gulp.src('src/index.html')
.pipe(gulp.dest('dist/latest/'));
gulp.src('src/indexV3.html')
.pipe(gulp.dest('dist/latest/'));
// copy testdata
gulp.src('src/testdata/*')
.pipe(gulp.dest('dist/latest/testdata/'));
return gulp.src('src/main.ts')
.pipe(plumber({
errorHandler: function (error) {
console.log(error.plugin, error.message, '\n');
return this.emit('end');
}
}))
.pipe(webpack( require('./webpack.config.js') ))
.pipe(rename('bootstrap-autocomplete.js'))
.pipe(gulp.dest('dist/latest/'));
});
gulp.task('dist-min', function () {
return gulp.src('dist/latest/bootstrap-autocomplete.js')
.pipe(rename({
extname: '.min.js'
}))
.pipe(size({title: 'PRE-MINIFY'}))
.pipe(uglify({ mangle:true }))
.pipe(size({title: 'POST-MINIFY'}))
.pipe(gulp.dest('dist/latest'));
});
gulp.task('dev-server', function() {
browserSync({
server: {
baseDir: 'dist/latest'
},
open: false,
});
gulp.watch(['*.html', '*.js', 'testdata/*'], {cwd: 'dist/latest'}, reload);
/*
gulp.src('dist/latest')
.pipe(server({
host: '0.0.0.0',
livereload: {
enable: true,
clientConsole: false
}
}));
*/
});