-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-assets.sh
executable file
·34 lines (30 loc) · 946 Bytes
/
build-assets.sh
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
#!/bin/bash
# Solve the JavaScript heap out of memory
export NODE_OPTIONS='--max-old-space-size=4096'
ENV_MODE=$1
# Prints an information block (aka header)
function printInfoBlock() {
LINES="\n========================================\n";
printf "$LINES";
printf "$1"
printf "$LINES \n";
}
START=$(date +%s) && \
\
printInfoBlock "Executing VITE build process" && \
npx vite build --mode "${ENV_MODE}" && \
\
# This has to be made outside vite as otherwise it breaks the js code, consumes tremendous amount of resources & time
## It can happen that obfuscated code will get slower
printInfoBlock "Obfuscating code" && \
npx javascript-obfuscator dist --output=dist && \
\
# This allows some browsers to take the gzip version (smaller one)
printInfoBlock "Compressing files" && \
gzip --keep dist/assets/*.js && \
\
\
END=$(date +%s) && \
RUNTIME=$(($END- $START)) && \
\
printInfoBlock "Script was running ${RUNTIME} second/s";