Skip to content

Commit 3dd9917

Browse files
author
Luc
committed
Allow to build en + 1 language to decrease FW size
Set gzip compression to 9
1 parent b57b3bd commit 3dd9917

24 files changed

+6738
-10
lines changed

buildLanguagePacks.bat

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
cd %~dp0
2+
rmdir /Q /S languages
3+
mkdir languages\en
4+
cmd.exe /c gulp package --lang en
5+
copy index.html.gz languages\en
6+
mkdir languages\fr
7+
cmd.exe /c gulp package --lang fr
8+
copy index.html.gz languages\fr
9+
mkdir languages\es
10+
cmd.exe /c gulp package --lang es
11+
copy index.html.gz languages\es
12+
mkdir languages\it
13+
cmd.exe /c gulp package --lang it
14+
copy index.html.gz languages\it
15+
mkdir languages\de
16+
cmd.exe /c gulp package --lang de
17+
copy index.html.gz languages\de
18+
mkdir languages\pl
19+
cmd.exe /c gulp package --lang pl
20+
copy index.html.gz languages\pl
21+
mkdir languages\ptbr
22+
cmd.exe /c gulp package --lang ptbr
23+
copy index.html.gz languages\ptbr
24+
mkdir languages\ru
25+
cmd.exe /c gulp package --lang ru
26+
copy index.html.gz languages\ru
27+
mkdir languages\uk
28+
cmd.exe /c gulp package --lang uk
29+
copy index.html.gz languages\uk
30+
cmd.exe /c gulp package
31+
mkdir languages\multi
32+
copy index.html.gz languages\multi
33+
pause

gulpfile.js

Lines changed: 129 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@ var gulp = require('gulp'),
1313
replace = require('gulp-replace'),
1414
fs = require('fs'),
1515
smoosher = require('gulp-smoosher');
16+
size = require('gulp-filesize');
1617

17-
var demoMode = false;
18-
var testMode = false;
18+
var en_lang = true;
19+
var fr_lang = false;
20+
var es_lang = false;
21+
var de_lang = false;
22+
var it_lang = false;
23+
var pl_lang = false;
24+
var ptbr_lang = false;
25+
var ru_lang = false;
26+
var uk_lang = false;
1927

2028
function clean() {
2129
return del(['dist']);
30+
2231
}
2332

2433
function clean2() {
@@ -35,7 +44,7 @@ function Copytest() {
3544
gulp.src(['www/index.html'])
3645
.pipe(removeCode({production: false}))
3746
.pipe(removeCode({cleanheader: true}))
38-
.pipe(gulp.dest('dist')),
47+
.pipe(gulp.dest('dist')),
3948
gulp.src(['www/images/**/*.*'])
4049
.pipe(gulp.dest('dist/images'))
4150
)
@@ -46,7 +55,7 @@ function Copy() {
4655
gulp.src(['www/index.html'])
4756
.pipe(removeCode({production: true}))
4857
.pipe(removeCode({cleanheader: true}))
49-
.pipe(gulp.dest('dist')),
58+
.pipe(gulp.dest('dist')),
5059
gulp.src(['www/images/**/*.*'])
5160
.pipe(gulp.dest('dist/images'))
5261
)
@@ -88,6 +97,116 @@ function replaceSVG() {
8897
.pipe(gulp.dest('dist'))
8998
}
9099

100+
function clearlang() {
101+
// fetch command line arguments
102+
console.log("Enable Language:");
103+
const arg = (argList => {
104+
105+
let arg = {}, a, opt, thisOpt, curOpt;
106+
for (a = 0; a < argList.length; a++) {
107+
108+
thisOpt = argList[a].trim();
109+
opt = thisOpt.replace(/^\-+/, '');
110+
111+
if (opt === thisOpt) {
112+
113+
// argument value
114+
if (curOpt) arg[curOpt] = opt;
115+
curOpt = null;
116+
117+
}
118+
else {
119+
120+
// argument name
121+
curOpt = opt;
122+
arg[curOpt] = true;
123+
124+
}
125+
126+
}
127+
128+
return arg;
129+
130+
})(process.argv);
131+
132+
if ((typeof arg.lang == 'undefined') || (arg.lang == 'all')) {
133+
en_lang = true;
134+
fr_lang = true;
135+
es_lang = true;
136+
de_lang = true;
137+
it_lang = true;
138+
pl_lang = true;
139+
ptbr_lang = true;
140+
ru_lang = true;
141+
uk_lang = true;
142+
}
143+
if (arg.lang == 'en'){
144+
en_lang = true;
145+
}
146+
if(en_lang){
147+
console.log("en");
148+
}
149+
if (arg.lang == 'fr'){
150+
fr_lang = true;
151+
}
152+
if(fr_lang){
153+
console.log("fr");
154+
}
155+
if (arg.lang == 'es'){
156+
es_lang = true;
157+
}
158+
if(es_lang){
159+
console.log("es");
160+
}
161+
if (arg.lang == 'de'){
162+
de_lang = true;
163+
}
164+
if(de_lang){
165+
console.log("de");
166+
}
167+
if (arg.lang == 'it'){
168+
it_lang = true;
169+
}
170+
if(it_lang){
171+
console.log("it");
172+
}
173+
if (arg.lang == 'pl'){
174+
pl_lang = true;
175+
}
176+
if(pl_lang){
177+
console.log("pl");
178+
}
179+
if (arg.lang == 'ptbr'){
180+
ptbr_lang = true;
181+
}
182+
if(ptbr_lang){
183+
console.log("ptbr");
184+
}
185+
if (arg.lang == 'ru'){
186+
ru_lang = true;
187+
}
188+
if(ru_lang){
189+
console.log("ru");
190+
}
191+
if (arg.lang == 'uk'){
192+
uk_lang = true;
193+
}
194+
if(uk_lang){
195+
console.log("uk");
196+
}
197+
return gulp.src('dist/js/app.js')
198+
.pipe(removeCode({de_lang_disabled: !de_lang}))
199+
.pipe(removeCode({en_lang_disabled: !en_lang}))
200+
.pipe(removeCode({es_lang_disabled: !es_lang}))
201+
.pipe(removeCode({fr_lang_disabled: !fr_lang}))
202+
.pipe(removeCode({it_lang_disabled: !it_lang}))
203+
.pipe(removeCode({pl_lang_disabled: !pl_lang}))
204+
.pipe(removeCode({ptbr_lang_disabled: !ptbr_lang}))
205+
.pipe(removeCode({ru_lang_disabled: !ru_lang}))
206+
.pipe(removeCode({uk_lang_disabled: !uk_lang}))
207+
.pipe(gulp.dest('./dist/js/'))
208+
}
209+
91210
function minifyApp() {
92211
return merge(
93212
gulp.src(['dist/js/app.js'])
@@ -125,10 +244,12 @@ function smoosh() {
125244

126245
function compress() {
127246
return gulp.src('dist/index.html')
128-
.pipe(gzip())
129-
.pipe(gulp.dest('.'));
247+
.pipe(gzip({ gzipOptions: { level: 9} }))
248+
.pipe(gulp.dest('.'))
249+
.pipe(size());
130250
}
131251

252+
132253
gulp.task(clean);
133254
gulp.task(lint);
134255
gulp.task(Copy);
@@ -139,10 +260,11 @@ gulp.task(concatApptest);
139260
gulp.task(minifyApp);
140261
gulp.task(smoosh);
141262
gulp.task(clean2);
263+
gulp.task(clearlang)
142264

143265
var defaultSeries = gulp.series(clean, lint, Copy, concatApp, minifyApp, includehtml, includehtml, smoosh);
144266
//var packageSeries = gulp.series(clean, lint, Copy, concatApp, minifyApp, smoosh, compress);
145-
var packageSeries = gulp.series(clean, lint, Copy, concatApp, includehtml, includehtml, replaceSVG, minifyApp, smoosh, compress, clean2);
267+
var packageSeries = gulp.series(clean, lint, Copy, concatApp, includehtml, includehtml, replaceSVG, clearlang, minifyApp, smoosh, compress, clean2);
146268
var package2Series = gulp.series(clean, lint, Copy, concatApp, includehtml, includehtml, replaceSVG, smoosh);
147269
var package2testSeries = gulp.series(clean, lint, Copytest, concatApptest, includehtml, includehtml, replaceSVG, smoosh);
148270

index.html.gz

-1.11 KB
Binary file not shown.

languages/de/index.html.gz

99 KB
Binary file not shown.

languages/en/index.html.gz

95.6 KB
Binary file not shown.

languages/es/index.html.gz

98.6 KB
Binary file not shown.

languages/fr/index.html.gz

95.6 KB
Binary file not shown.

languages/it/index.html.gz

98.6 KB
Binary file not shown.

languages/multi/index.html.gz

123 KB
Binary file not shown.

languages/pl/index.html.gz

99.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)