forked from maxpert/raspchat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (79 loc) · 2.45 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
var gulp = require('gulp'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
browserify = require('gulp-browserify'),
htmlmin = require('gulp-htmlmin'),
rev = require('gulp-rev-append'),
argv = require('yargs').alias('p', 'production').argv;
var Settings = {
assets: {
source: [
'static/index.html',
'static/welcome.html',
'static/*.svg',
'static/*.png',
'static/*.jpg',
'static/*.gif',
'static/*.css',
'static/*.ttf',
'static/favicon/**/*',
'static/images/**/*'
],
sourceBase: './static',
output: 'dist/static'
},
js: {
sourceFile: 'chat.js',
outputFile: 'app.js',
static: 'static',
source: 'static/js',
output: 'dist/static',
server: {
src: 'src/*.js',
dest: 'dist/server'
}
},
html: {
minify: {
collapseWhitespace: true,
conservativeCollapse: true,
},
source: 'static',
output: 'dist/static'
}
};
gulp.task('process-htmls', function () {
return gulp.src( Settings.html.source + '/chat.html')
.pipe(rev())
.pipe(htmlmin(Settings.html.minify))
.pipe(rename('chat.html'))
.pipe(gulp.dest(Settings.html.output));
});
gulp.task('compile-js', function () {
return gulp.src(Settings.js.source + '/' + Settings.js.sourceFile)
.pipe(browserify({
insertGlobals : true,
debug : !argv.p
}))
.pipe(rename(Settings.js.outputFile))
.pipe(gulp.dest(Settings.js.static));
});
gulp.task('copy-assets', function () {
return gulp.src(Settings.assets.source, {base: Settings.assets.sourceBase})
.pipe(gulp.dest(Settings.assets.output));
});
gulp.task('compile-assets', gulp.series('copy-assets', 'compile-js', 'process-htmls', function () {
return gulp.src(Settings.js.static + '/' + Settings.js.outputFile)
.pipe(uglify())
.pipe(rename(Settings.js.outputFile))
.pipe(gulp.dest(Settings.js.output));
}));
gulp.task('dist-package', function() {
return gulp.src('package*.json')
.pipe(gulp.dest('dist'));
});
gulp.task('dist-src', function() {
return gulp.src(Settings.js.server.src)
.pipe(gulp.dest(Settings.js.server.dest));
});
gulp.task('default', gulp.series('compile-assets', 'dist-src', 'dist-package'));