Problem: Production zip was only 692K instead of expected 2.5MB+ Root Cause: Global --exclude='dist' was removing SPA build folders Solution: - Removed global dist exclusion - Added specific exclusions for dev config files: - tailwind.config.js/cjs - postcss.config.js/cjs - .eslintrc.cjs - components.json - .cert directory Result: ✅ Production zip now 5.2M (correct size) ✅ Customer SPA dist included (480K) ✅ Admin SPA dist included (2.6M) ✅ No dev config files in package Verified: - Activation hook creates pages with correct shortcodes: - [woonoow_shop] - [woonoow_cart] - [woonoow_checkout] - [woonoow_account] - Installer reuses existing WooCommerce pages if available - Sets WooCommerce HPOS enabled on activation
111 lines
3.3 KiB
Bash
Executable File
111 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# WooNooW Plugin - Production Build Script
|
|
# This script creates a production-ready zip file of the plugin
|
|
|
|
set -e # Exit on error
|
|
|
|
PLUGIN_NAME="woonoow"
|
|
VERSION=$(grep "Version:" woonoow.php | awk '{print $3}')
|
|
BUILD_DIR="build"
|
|
DIST_DIR="dist"
|
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
|
ZIP_NAME="${PLUGIN_NAME}-${VERSION}-${TIMESTAMP}.zip"
|
|
|
|
echo "=========================================="
|
|
echo "WooNooW Production Build"
|
|
echo "=========================================="
|
|
echo "Plugin: ${PLUGIN_NAME}"
|
|
echo "Version: ${VERSION}"
|
|
echo "Timestamp: ${TIMESTAMP}"
|
|
echo "=========================================="
|
|
|
|
# Clean previous builds
|
|
echo "Cleaning previous builds..."
|
|
rm -rf ${BUILD_DIR}
|
|
mkdir -p ${BUILD_DIR}/${PLUGIN_NAME}
|
|
mkdir -p ${DIST_DIR}
|
|
|
|
# Copy plugin files
|
|
echo "Copying plugin files..."
|
|
rsync -av --progress \
|
|
--exclude='node_modules' \
|
|
--exclude='.git' \
|
|
--exclude='.gitignore' \
|
|
--exclude='build' \
|
|
--exclude='*.log' \
|
|
--exclude='.DS_Store' \
|
|
--exclude='customer-spa/src' \
|
|
--exclude='customer-spa/public' \
|
|
--exclude='customer-spa/node_modules' \
|
|
--exclude='customer-spa/.vite' \
|
|
--exclude='customer-spa/package.json' \
|
|
--exclude='customer-spa/package-lock.json' \
|
|
--exclude='customer-spa/vite.config.ts' \
|
|
--exclude='customer-spa/tsconfig.json' \
|
|
--exclude='customer-spa/tsconfig.node.json' \
|
|
--exclude='customer-spa/index.html' \
|
|
--exclude='customer-spa/tailwind.config.js' \
|
|
--exclude='customer-spa/postcss.config.js' \
|
|
--exclude='customer-spa/.eslintrc.cjs' \
|
|
--exclude='admin-spa/src' \
|
|
--exclude='admin-spa/public' \
|
|
--exclude='admin-spa/node_modules' \
|
|
--exclude='admin-spa/.vite' \
|
|
--exclude='admin-spa/.cert' \
|
|
--exclude='admin-spa/package.json' \
|
|
--exclude='admin-spa/package-lock.json' \
|
|
--exclude='admin-spa/vite.config.ts' \
|
|
--exclude='admin-spa/tsconfig.json' \
|
|
--exclude='admin-spa/tsconfig.node.json' \
|
|
--exclude='admin-spa/index.html' \
|
|
--exclude='admin-spa/tailwind.config.js' \
|
|
--exclude='admin-spa/tailwind.config.cjs' \
|
|
--exclude='admin-spa/postcss.config.js' \
|
|
--exclude='admin-spa/postcss.config.cjs' \
|
|
--exclude='admin-spa/components.json' \
|
|
--exclude='admin-spa/.eslintrc.cjs' \
|
|
--exclude='examples' \
|
|
--exclude='*.sh' \
|
|
--exclude='*.md' \
|
|
./ ${BUILD_DIR}/${PLUGIN_NAME}/
|
|
|
|
# Verify production builds exist in source before copying
|
|
echo "Verifying production builds..."
|
|
if [ ! -f "customer-spa/dist/app.js" ]; then
|
|
echo "ERROR: Customer SPA production build not found!"
|
|
echo "Please run: cd customer-spa && npm run build"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "admin-spa/dist/app.js" ]; then
|
|
echo "ERROR: Admin SPA production build not found!"
|
|
echo "Please run: cd admin-spa && npm run build"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Customer SPA build verified ($(du -h customer-spa/dist/app.js | cut -f1))"
|
|
echo "✓ Admin SPA build verified ($(du -h admin-spa/dist/app.js | cut -f1))"
|
|
|
|
# Create zip file
|
|
echo "Creating zip file..."
|
|
cd ${BUILD_DIR}
|
|
zip -r ../${DIST_DIR}/${ZIP_NAME} ${PLUGIN_NAME} -q
|
|
cd ..
|
|
|
|
# Calculate file size
|
|
FILE_SIZE=$(du -h ${DIST_DIR}/${ZIP_NAME} | cut -f1)
|
|
|
|
echo "=========================================="
|
|
echo "✓ Production build complete!"
|
|
echo "=========================================="
|
|
echo "File: ${DIST_DIR}/${ZIP_NAME}"
|
|
echo "Size: ${FILE_SIZE}"
|
|
echo "=========================================="
|
|
|
|
# Clean up build directory
|
|
echo "Cleaning up..."
|
|
rm -rf ${BUILD_DIR}
|
|
|
|
echo "Done! 🚀"
|