-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
84 lines (72 loc) · 2.09 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
const gulp = require('gulp');
const handlebars = require('gulp-handlebars');
const wrap = require('gulp-wrap');
const declare = require('gulp-declare');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const del = require('del');
gulp.task('clean', function () {
return del(['./dist/**/*']);
});
gulp.task('handlebars', function () {
return gulp.src('./frontend/hbsTemplates/*.hbs')
.pipe(handlebars({handlebars: require("handlebars")}))
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'RadioWars.templates',
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat('hbsTemplates.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js/'));
});
gulp.task('moveHTML', function () {
return gulp.src('./frontend/*.html')
.pipe(gulp.dest('dist'));
});
gulp.task('combineFrontendJs', function () {
return gulp.src('./frontend/js/**/*.js')
.pipe(concat('compiled.js'))
// .pipe(insert.wrap(";(function(){","\n})();")) Need to generate page to do
.pipe(uglify())
.pipe(gulp.dest('dist/js/'));
});
gulp.task('combineCSS', function () {
return gulp.src('./frontend/css/**/*.css')
.pipe(concat('combined.css'))
.pipe(gulp.dest('dist/css/'));
});
gulp.task('moveIndexJS', function () {
return gulp.src('./server/index.js')
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('moveServerJSON', function () {
return gulp.src('./server/*.json')
.pipe(gulp.dest('dist'));
});
gulp.task('movePackageJSON', function () {
return gulp.src('./package.json')
.pipe(gulp.dest('dist'));
});
gulp.task('moveConfigFile', function () {
return gulp.src('./server/config.js')
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('moveMaps', function () {
return gulp.src('./server/maps/*.json')
.pipe(gulp.dest('dist/maps'));
});
gulp.task('default', gulp.series(
'clean',
gulp.parallel(
gulp.series('handlebars', 'moveHTML'),
'movePackageJSON',
'combineFrontendJs',
'combineCSS',
'moveIndexJS',
'moveServerJSON',
'moveMaps'
)
));