-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
87 lines (77 loc) · 1.86 KB
/
gulpfile.js
File metadata and controls
87 lines (77 loc) · 1.86 KB
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
'use strict';
var gulp = require('gulp'),
gutil = require('gulp-util'),
gzip = require('gulp-gzip'),
cssmin = require('gulp-cssmin'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
replace = require('gulp-replace'),
htmlmin = require('gulp-htmlmin'),
luaminify = require('gulp-luaminify'),
rigger = require('gulp-rigger');
var path = {
build: 'files/',
src: {
html: 'src/*.html',
js: 'src/assets/js/**/*.js',
style: 'src/assets/css/*.css',
img: 'src/assets/images/**/*.*',
lua: 'src/lua/**/*.*',
info: 'src/assets/info/**/*.*',
fonts: 'src/assets/fonts/**/*.*'
},
watch: {
html: 'src/**/*.html',
js: 'src/assets/js/*.js',
style: 'src/assets/css/*.css',
img: 'src/assets/images/**/*.*',
lua: 'src/lua/**/*.*',
info: 'src/assets/info/**/*.*',
fonts: 'src/assets/fonts/**/*.*'
},
clean: './build'
};
var optionsDef = {
collapseWhitespace: true,
minifyCSS:true,
removeComments:true,
minifyJS:true
};
function html () {
return gulp.src(path.src.html)
.pipe(rigger())
.pipe(htmlmin(optionsDef))
.pipe(replace('<?lua', '\n<?lua'))
.pipe(gulp.dest(path.build));
};
function js() {
return gulp.src(path.src.js)
.pipe(rigger())
.pipe(uglify())
.pipe(gzip())
.pipe(gulp.dest(path.build));
};
function style() {
return gulp.src(path.src.style)
.pipe(cssmin())
.pipe(rename({basename: "style"}))
.pipe(gzip())
.pipe(gulp.dest(path.build));
};
function img() {
return gulp.src(path.src.img)
.pipe(gulp.dest(path.build));
};
function lua() {
return gulp.src(path.src.lua)
.pipe(luaminify())
.pipe(gulp.dest(path.build));
};
function watch() {
gulp.watch(path.watch.html, html);
gulp.watch(path.watch.js, js);
gulp.watch(path.watch.lua, lua);
gulp.watch(path.watch.style, style);
}
gulp.task('build', gulp.parallel(html, js, style, img, lua));
gulp.task('watch', gulp.series(watch));