This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
159 lines (142 loc) · 4.16 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* eslint-disable import/no-commonjs, node/no-unpublished-require, import/max-dependencies */
const {join} = require("path")
const gulp = require("gulp")
const gulpConcat = require("gulp-concat")
const gulpMyth = require("gulp-myth")
const gulpSize = require("gulp-size")
const gulpGzip = require("gulp-gzip")
const gulpBabel = require("gulp-babel")
const browserify = require("browserify")
const babelify = require("babelify")
const envify = require("envify")
const vinylSourceStream = require("vinyl-source-stream")
const vinylBuffer = require("vinyl-buffer")
const gulpChanged = require("gulp-changed")
const gulpUglify = require("gulp-uglify")
const {production} = require("gulp-environments")
const DESINATION = "./transpiled/"
const GZIP = {
append: true,
threshold: true,
gzipOptions: {
level: 9,
memLevel: 9,
},
}
gulp.task("build:@lacqueristas", () => {
const destination = join(DESINATION, "@lacqueristas")
return gulp.src([
"./source/@lacqueristas/**/*.js",
])
.pipe(gulpChanged(destination))
.pipe(gulpBabel())
.pipe(gulpSize({
title: "@lacqueristas",
showFiles: true,
}))
.pipe(gulp.dest(destination))
})
gulp.task("build:server", ["build:@lacqueristas"], () => {
const destination = join(DESINATION, "server")
return gulp.src([
"./source/server/**/*.js",
])
.pipe(gulpChanged(destination))
.pipe(gulpBabel())
.pipe(gulpSize({
title: "server",
showFiles: true,
}))
.pipe(gulp.dest(destination))
})
gulp.task("build:client", ["build:styles", "build:images", "build:assets", "build:fonts"], () => {
const destination = join(DESINATION, "client")
return browserify({
entries: "./source/client/index.js",
transform: [
[babelify, {ignore: "./source/**/test.js"}],
envify,
],
})
.bundle()
.pipe(vinylSourceStream("index.js"))
.pipe(vinylBuffer())
.pipe(production(gulpUglify()))
.pipe(production(gulp.dest(destination)))
.pipe(production(gulpGzip(GZIP)))
.pipe(gulpSize({
title: "client",
showFiles: true,
}))
.pipe(gulp.dest(destination))
})
gulp.task("build:styles", () => {
const destination = join(DESINATION, "client")
return gulp.src([
"./node_modules/font-awesome/css/font-awesome.css",
"./node_modules/normalize.css/normalize.css",
"./node_modules/skeleton-css/css/skeleton.css",
"./source/client/index.css",
])
.pipe(gulpChanged(destination))
.pipe(gulpConcat("index.css"))
.pipe(gulpMyth())
.pipe(production(gulp.dest(destination)))
.pipe(production(gulpGzip(GZIP)))
.pipe(gulpSize({
title: "styles",
showFiles: true,
}))
.pipe(gulp.dest(destination))
})
gulp.task("build:images", () => {
const destination = join(DESINATION, "client")
return gulp.src([
"./source/images/*.png",
"./source/images/*.ico",
])
.pipe(gulpChanged(destination))
.pipe(production(gulp.dest(destination)))
.pipe(production(gulpGzip(GZIP)))
.pipe(gulpSize({
title: "images",
showFiles: true,
}))
.pipe(gulp.dest(destination))
})
gulp.task("build:assets", () => {
const destination = join(DESINATION, "client")
return gulp.src([
"./source/assets/browserconfig.xml",
"./source/assets/manifest.json",
"./source/assets/loadtestertool.xml",
"./source/assets/babel-helpers.js",
])
.pipe(gulpChanged(destination))
.pipe(production(gulp.dest(destination)))
.pipe(production(gulpGzip(GZIP)))
.pipe(gulpSize({
title: "assets",
showFiles: true,
}))
.pipe(gulp.dest(destination))
})
gulp.task("build:fonts", () => {
const destination = join(DESINATION, "client", "fonts")
return gulp.src([
"./node_modules/font-awesome/fonts/**/*",
])
.pipe(gulpChanged(destination))
.pipe(production(gulp.dest(destination)))
.pipe(production(gulpGzip(GZIP)))
.pipe(gulpSize({
title: "fonts",
showFiles: true,
}))
.pipe(gulp.dest(destination))
})
gulp.task("build:build", ["build:server", "build:client"])
gulp.task("build:watch", ["build:server", "build:client"], () => {
gulp.watch("./source/server/**/*", ["build:server"])
gulp.watch("./source/client/**/*", ["build:client"])
})