Skip to content

Instantly share code, notes, and snippets.

@John-Gee
Last active November 24, 2025 14:35
Show Gist options
  • Select an option

  • Save John-Gee/c4792dc33976464c7428983d59ab03aa to your computer and use it in GitHub Desktop.

Select an option

Save John-Gee/c4792dc33976464c7428983d59ab03aa to your computer and use it in GitHub Desktop.
trim seerr
# -----------------------------------------------------------
# SAFE CLEANUP: Remove Build Caches (~600MB reduction)
# -----------------------------------------------------------
echo "Removing build caches..."
# 2. Delete Webpack/Terser caches in node_modules
rm -rf "$pkgdir/usr/lib/$pkgname/node_modules/.cache"
# 3. Prune text files (Optional, requires node-prune)
if command -v node-prune &> /dev/null; then
node-prune "$pkgdir/usr/lib/$pkgname/node_modules" || true
fi
# -----------------------------------------------------------
# POST-INSTALL CLEANUP (~400MB+ Reduction)
# -----------------------------------------------------------
echo "Performing safe cleanup..."
cd "$pkgdir/usr/lib/$pkgname"
# 1. Remove Source Maps (Pure debugging files, 100% safe)
find . -name "*.map" -type f -delete
# 2. Remove Foreign Architectures (Binaries for other OSs)
# - Remove Alpine Linux (musl) binaries (Arch uses glibc)
find node_modules -type d -name "*-musl*" -exec rm -rf {} +
# - Remove Android/Mobile artifacts (Web app only)
#find node_modules -type d -name "*android*" -exec rm -rf {} +
#find node_modules -type d -name "react-native" -exec rm -rf {} +
# - Remove macOS/Windows binaries (If they exist)
find node_modules -type f \( -name "*.dylib" -o -name "*.dll" -o -name "*.exe" \) -delete
# 3. Remove TypeScript Compiler (Production runs compiled JS)
find node_modules -type d -name "typescript" -exec rm -rf {} +
# 4. Remove Documentation & Tests (Text file bloat)
find node_modules -type f \( -name "*.md" -o -name "*.markdown" -o -name "LICENSE" \) -delete
find node_modules -type d -name "test" -exec rm -rf {} +
find node_modules -type d -name "__tests__" -exec rm -rf {} +
# -----------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment