import fs from 'fs-extra'; import path from 'path'; async function copyBuild() { const sourcePath = path.resolve(__dirname, '../build'); const targetPath = path.resolve(__dirname, '../../inventory-server/frontend/build'); try { // Ensure the target directory exists await fs.ensureDir(path.dirname(targetPath)); // Remove old build if it exists await fs.remove(targetPath); // Copy new build await fs.copy(sourcePath, targetPath); console.log('Build files copied successfully to server directory!'); } catch (error) { console.error('Error copying build files:', error); process.exit(1); } } copyBuild();