Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
183 lines (154 loc) Β· 7.12 KB
/
Copy pathbuild.sh
File metadata and controls
183 lines (154 loc) Β· 7.12 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
# WebDev-Tools Simple Build Script
# Copies files to dist/ and minifies CSS only
# No JavaScript bundling - individual files are used
set -e # Exit on error
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$SCRIPT_DIR"
DIST_DIR="$PROJECT_ROOT/dist"
BUILD_HASH=$(date +%s | sha256sum | cut -c1-8)
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β ποΈ WebDev-Tools Simple Build (No Bundling) β"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "π¦ Build Hash: $BUILD_HASH"
echo "π― Target: $DIST_DIR"
echo ""
# ============================================
# 1. Clean & Setup
# ============================================
echo "π§Ή Cleaning previous build..."
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"/{assets/{css,js,img,data,bootstrap},config/i18n,partials}
# Tells build-tools/check-deploy.sh which commit this build belongs to
if [ -n "$(git status --porcelain)" ]; then
echo "uncommitted changes" > "$PROJECT_ROOT/.build-commit"
else
git rev-parse HEAD > "$PROJECT_ROOT/.build-commit"
fi
# ============================================
# 2. Copy PHP Files
# ============================================
echo "π Copying PHP files..."
# Root PHP files
cp *.php "$DIST_DIR/" 2>/dev/null || true
cp *.htm "$DIST_DIR/" 2>/dev/null || true
cp *.txt "$DIST_DIR/" 2>/dev/null || true
cp *.webmanifest "$DIST_DIR/" 2>/dev/null || true
cp favicon.ico "$DIST_DIR/" 2>/dev/null || true
[ -d ".well-known" ] && cp -r .well-known "$DIST_DIR/"
# Copy production htaccess (not dev version!)
if [ -f ".htaccess.production" ]; then
cp .htaccess.production "$DIST_DIR/.htaccess"
echo " β Using .htaccess.production for build"
else
cp .htaccess "$DIST_DIR/" 2>/dev/null || true
echo " β Using development .htaccess (production version not found)"
fi
# Generate fresh sitemaps
if [ -f "config/generate-sitemaps.php" ]; then
echo "πΊοΈ Generating sitemaps..."
php config/generate-sitemaps.php
fi
# Copy sitemaps
cp *.xml "$DIST_DIR/" 2>/dev/null || true
# Partials
cp -r partials "$DIST_DIR/"
# Config
cp -r config/*.php "$DIST_DIR/config/"
# Regenerate the manifest so its content-hash version matches the scripts and translations being shipped
php config/generate-manifest.php > /dev/null
cp config/manifest.json "$DIST_DIR/config/"
# ============================================
# 3. Copy JavaScript (No bundling!)
# ============================================
echo "π¦ Copying JavaScript files..."
cp -r assets/js "$DIST_DIR/assets/"
# ============================================
# 4. Copy & Minify CSS
# ============================================
echo "π¨ Processing CSS..."
mkdir -p "$DIST_DIR/assets/css"
# Prefer the project's csso (devDependency) over a global install
CSSO_BIN="./node_modules/.bin/csso"
[ -x "$CSSO_BIN" ] || CSSO_BIN=$(command -v csso || true)
if [ -n "$CSSO_BIN" ]; then
for css_file in assets/css/*.css; do
filename=$(basename "$css_file")
"$CSSO_BIN" "$css_file" -o "$DIST_DIR/assets/css/$filename"
done
echo " β CSS minified with csso"
else
cp -r assets/css/* "$DIST_DIR/assets/css/"
echo " β csso not installed, using original CSS"
fi
# ============================================
# 5. Build Custom Bootstrap
# ============================================
echo "π¦ Building Custom Bootstrap..."
mkdir -p "$DIST_DIR/assets/bootstrap/css"
# β οΈ WICHTIG: Bei neuen Tools prΓΌfen, ob zusΓ€tzliche Bootstrap-Komponenten
# in build-tools/bootstrap-custom.scss importiert werden mΓΌssen!
# Aktuelle Komponenten: buttons, nav, navbar, card, badge, alert, close,
# accordion, tables, forms, input-group, dropdown, button-group, transitions,
# modal, tooltip, offcanvas, toasts
# NICHT importiert: breadcrumb, carousel, list-group, pagination,
# placeholders, popovers, progress, spinners
if command -v npx &> /dev/null && npx sass --version &> /dev/null; then
npx sass build-tools/bootstrap-custom.scss "$DIST_DIR/assets/bootstrap/css/bootstrap.min.css" \
--style=compressed --no-source-map
ORIGINAL_SIZE=$(stat -f%z "assets/bootstrap/css/bootstrap.min.css" 2>/dev/null || stat -c%s "assets/bootstrap/css/bootstrap.min.css")
CUSTOM_SIZE=$(stat -f%z "$DIST_DIR/assets/bootstrap/css/bootstrap.min.css" 2>/dev/null || stat -c%s "$DIST_DIR/assets/bootstrap/css/bootstrap.min.css")
REDUCTION=$(echo "scale=1; 100 - ($CUSTOM_SIZE * 100 / $ORIGINAL_SIZE)" | bc)
echo " β Custom Bootstrap compiled (${CUSTOM_SIZE} bytes, ${REDUCTION}% Reduktion)"
else
cp -r assets/bootstrap "$DIST_DIR/assets/"
echo " β sass not available, using original Bootstrap (228KB)"
fi
# Bootstrap JS is not part of the custom Sass build but is loaded by partials/footer.php
mkdir -p "$DIST_DIR/assets/bootstrap/js"
cp assets/bootstrap/js/bootstrap.bundle.min.js "$DIST_DIR/assets/bootstrap/js/"
# Copy Bootstrap Icons
cp -r assets/bootstrap-icons "$DIST_DIR/assets/" 2>/dev/null || true
# ============================================
# 6. Copy Static Assets
# ============================================
echo "πΌοΈ Copying static assets..."
cp -r assets/img "$DIST_DIR/assets/"
cp -r assets/data "$DIST_DIR/assets/"
# ============================================
# 7. Copy i18n
# ============================================
echo "π Copying i18n files..."
cp config/i18n/*.json "$DIST_DIR/config/i18n/"
# ============================================
# 8. Copy Tool Directories
# ============================================
echo "π§ Copying tool directories..."
for tool_dir in uuid-generator password-generator hash-generator base64-encoder-decoder \
json-formatter-validator code-formatter data-converter url-encoder-decoder \
html-entity-encoder-decoder jwt-decoder punycode-converter string-escaper \
regex-tester px-to-rem-converter aspect-ratio-calculator lorem-ipsum \
qr-code-generator sri-generator character-reference emoji-reference; do
[ -d "$tool_dir" ] && cp -r "$tool_dir" "$DIST_DIR/"
done
# Language directories
for lang_dir in de es fr it pt; do
[ -d "$lang_dir" ] && cp -r "$lang_dir" "$DIST_DIR/"
done
# ============================================
# Done!
# ============================================
echo ""
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β
BUILD COMPLETE!"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
echo "π Build Summary:"
echo " No JavaScript bundling - all files loaded individually"
echo " CSS minified (if csso available)"
echo " All PHP, assets, and tools copied"
echo ""
echo "π Deployment Ready:"
echo " npm run deploy (FTP upload, see deploy.config.example)"
echo ""