diff --git a/build-production.sh b/build-production.sh index da0fc2f..0a0f25b 100755 --- a/build-production.sh +++ b/build-production.sh @@ -33,41 +33,17 @@ rsync -av --progress \ --exclude='.git' \ --exclude='.gitignore' \ --exclude='build' \ + --exclude='dist' \ --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='customer-spa' \ + --exclude='admin-spa' \ --exclude='examples' \ --exclude='*.sh' \ --exclude='*.md' \ + --exclude='archive' \ + --exclude='test-*.php' \ + --exclude='check-*.php' \ ./ ${BUILD_DIR}/${PLUGIN_NAME}/ # Verify production builds exist in source before copying @@ -87,6 +63,22 @@ 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))" +# Copy only essential SPA build files +echo "Copying SPA build files..." +mkdir -p ${BUILD_DIR}/${PLUGIN_NAME}/customer-spa/dist +mkdir -p ${BUILD_DIR}/${PLUGIN_NAME}/admin-spa/dist + +# Customer SPA - only app.js and app.css +cp customer-spa/dist/app.js ${BUILD_DIR}/${PLUGIN_NAME}/customer-spa/dist/ +cp customer-spa/dist/app.css ${BUILD_DIR}/${PLUGIN_NAME}/customer-spa/dist/ + +# Admin SPA - only app.js and app.css (no dynamic imports for now) +cp admin-spa/dist/app.js ${BUILD_DIR}/${PLUGIN_NAME}/admin-spa/dist/ +cp admin-spa/dist/app.css ${BUILD_DIR}/${PLUGIN_NAME}/admin-spa/dist/ + +echo "✓ Copied customer-spa: app.js ($(du -h customer-spa/dist/app.js | cut -f1)), app.css ($(du -h customer-spa/dist/app.css | cut -f1))" +echo "✓ Copied admin-spa: app.js ($(du -h admin-spa/dist/app.js | cut -f1)), app.css ($(du -h admin-spa/dist/app.css | cut -f1))" + # Create zip file echo "Creating zip file..." cd ${BUILD_DIR} diff --git a/includes/Api/ProductsController_taxonomy_methods.php b/includes/Api/ProductsController_taxonomy_methods.php new file mode 100644 index 0000000..e69de29 diff --git a/includes/Frontend/Assets.php b/includes/Frontend/Assets.php index bec275c..0b35403 100644 --- a/includes/Frontend/Assets.php +++ b/includes/Frontend/Assets.php @@ -75,51 +75,29 @@ class Assets { return; } - // Load manifest to get hashed filenames (Vite puts it in .vite/manifest.json) - $manifest_file = $dist_path . '.vite/manifest.json'; - if (file_exists($manifest_file)) { - $manifest = json_decode(file_get_contents($manifest_file), true); - - // Enqueue main JS - if (isset($manifest['src/main.tsx'])) { - $main_js = $manifest['src/main.tsx']['file']; - wp_enqueue_script( - 'woonoow-customer-spa', - $plugin_url . 'customer-spa/dist/' . $main_js, - [], - null, - true - ); + // Production build - load app.js and app.css directly + wp_enqueue_script( + 'woonoow-customer-spa', + $plugin_url . 'customer-spa/dist/app.js', + [], + null, + true + ); + + // Add type="module" for Vite build + add_filter('script_loader_tag', function($tag, $handle, $src) { + if ($handle === 'woonoow-customer-spa') { + $tag = str_replace('