forked from superluminar-io/hamburg.jeffconf.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
103 lines (89 loc) · 2.33 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
var gulp = require('gulp');
var htmlmin = require('gulp-htmlmin');
var minifyInline = require('gulp-minify-inline');
var uglify = require('gulp-uglify');
var pump = require('pump');
var browserSync = require('browser-sync').create();
var historyApiFallback = require('connect-history-api-fallback');
var fileinclude = require('gulp-file-include');
gulp.task('fileinclude', function() {
gulp.src(['src/views/index.html'])
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(htmlmin({collapseWhitespace: true, removeComments: true}))
.pipe(minifyInline())
.pipe(gulp.dest('dist'))
.pipe(browserSync.stream());
});
gulp.task('compress', function (cb) {
"use strict";
pump([
gulp.src('src/*.js'),
uglify(),
gulp.dest('dist')
], cb);
});
gulp.task('minify', ['fileinclude'], function () {
"use strict";
return gulp
.src('src/*.html')
.pipe(htmlmin({collapseWhitespace: true, removeComments: true}))
.pipe(minifyInline())
.pipe(gulp.dest('dist'));
});
gulp.task('copy', function () {
"use strict";
return gulp
.src([
'src/*.xml',
'src/*.css',
'src/*.txt',
'src/*.json'
])
.pipe(gulp.dest('dist'));
});
gulp.task('copy-libs', function () {
"use strict";
return gulp
.src([
'src/libs/**'
])
.pipe(gulp.dest('dist/libs'));
});
gulp.task('copy-imgs', function () {
"use strict";
return gulp
.src([
'src/imgs/**'
])
.pipe(gulp.dest('dist/imgs'));
});
gulp.task('build', [
'fileinclude', 'minify', 'copy', 'copy-libs', 'copy-imgs', 'compress'
]);
gulp.task('serve-dev', function () {
"use strict";
browserSync.init({
server: {
baseDir: "./src",
middleware: [historyApiFallback()]
}
});
});
gulp.task('include-watch', ['fileinclude'], browserSync.reload);
gulp.task('watch', ['fileinclude', 'serve-dev'], function () {
"use strict";
gulp.watch("./src/views/*.html", ['include-watch']);
});
gulp.task('serve-dist', ['build'], function () {
"use strict";
browserSync.init({
server: {
baseDir: "./dist",
middleware: [historyApiFallback()]
}
});
});
gulp.task('default', ['watch'] );