import * as fs from 'fs';
import * as path from 'path';
const rootDir = path.resolve(__dirname, '..');
const distDir = path.resolve(rootDir, 'dist');
const prodEnvPath = path.resolve(rootDir, '.env.production');
const devEnvPath = path.resolve(rootDir, '.env.development');
// Ensure dist directory exists
if (!fs.existsSync(distDir)) {
fs.mkdirSync(distDir, { recursive: true });
}
// Check if .env.production exists
if (fs.existsSync(prodEnvPath)) {
// Copy .env.production to dist folder
fs.copyFileSync(prodEnvPath, path.resolve(distDir, '.env.production'));
console.log('✅ .env.production copied to dist folder');
} else if (fs.existsSync(devEnvPath)) {
// Create .env.production based on .env.development
const devEnvContent = fs.readFileSync(devEnvPath, 'utf8');
fs.writeFileSync(path.resolve(distDir, '.env.production'), devEnvContent);
console.log('✅ .env.production created in dist folder based on .env.development');
} else {
console.warn('⚠️ Neither .env.production nor .env.development found');
}