-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-front.sh
executable file
·45 lines (34 loc) · 1.05 KB
/
build-front.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
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
! command -v html-minifier >/dev/null && npm install --global html-minifier
! command -v cssnano >/dev/null && npm install --global cssnano-cli
! command -v terser >/dev/null && npm install --global terser
minifyHTML() {
local input="$1"
local output="$2"
html-minifier \
--collapse-whitespace \
--remove-comments \
--remove-redundant-attributes \
--remove-script-type-attributes \
--remove-tag-whitespace \
--use-short-doctype \
"$input" \
-o "$output"
}
minifyCSS() {
local input="$1"
local output="$2"
cssnano "$input" "$output"
}
minifyJS() {
local input="$1"
local output="$2"
terser -c -m -e -o "$output" -- "$input"
}
[[ ! -d frontend/dist ]] && mkdir -p frontend/dist
minifyHTML frontend/index.html frontend/dist/index.html
minifyCSS frontend/style.css frontend/dist/style.css
minifyJS frontend/index.js frontend/dist/index.js
cp frontend/favicon* frontend/dist/
ls -l frontend/dist
git subtree push --prefix frontend/dist origin gh-pages