This repository was archived by the owner on Jan 4, 2026. It is now read-only.
forked from BetterSolano/bettersolano
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·59 lines (49 loc) · 1.71 KB
/
build.sh
File metadata and controls
executable file
·59 lines (49 loc) · 1.71 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
#!/bin/bash
# BetterSJDM Build Script
# Creates minified production files in dist/ folder
echo "Building BetterSJDM for production..."
# Auto-bump patch version (skip if --no-bump flag is passed)
if [ "$1" != "--no-bump" ] && [ -f "scripts/version.sh" ]; then
echo "Bumping version..."
./scripts/version.sh patch
fi
# Clean dist folder
rm -rf dist
mkdir -p dist
# Copy all files first
echo "Copying files..."
rsync -av --exclude='node_modules' --exclude='dist' --exclude='.git' --exclude='backup-restore-point-*' --exclude='package*.json' --exclude='build.sh' --exclude='.vscode' . dist/
# Minify HTML files
echo "Minifying HTML..."
find dist -name "*.html" -type f | while read file; do
npx html-minifier-terser \
--collapse-whitespace \
--remove-comments \
--remove-optional-tags \
--remove-redundant-attributes \
--remove-script-type-attributes \
--remove-style-link-type-attributes \
--minify-css true \
--minify-js true \
-o "$file" "$file"
done
# Minify CSS files
echo "Minifying CSS..."
find dist/assets/css -name "*.css" -type f | while read file; do
npx cleancss -o "$file" "$file"
done
# Minify JS files
echo "Minifying JavaScript..."
find dist/assets/js -name "*.js" -type f | while read file; do
npx terser "$file" -o "$file" --compress --mangle
done
# Calculate size savings
ORIG_SIZE=$(du -sh . --exclude=node_modules --exclude=dist --exclude=.git 2>/dev/null | cut -f1 || echo "N/A")
DIST_SIZE=$(du -sh dist 2>/dev/null | cut -f1 || echo "N/A")
echo ""
echo "Build complete!"
echo "Original size: $ORIG_SIZE"
echo "Minified size: $DIST_SIZE"
echo "Output: dist/"
echo ""
echo "To preview: cd dist && python3 -m http.server 8080"