kupos-ui-components-lib
Version:
A reusable UI components package
59 lines (46 loc) ⢠1.56 kB
JavaScript
const { exec } = require('child_process');
const fs = require('fs');
const path = require('path');
console.log('š Watching for changes in kupos-ui-components...');
console.log('š Watching: src/ directory');
console.log('š Auto-rebuild: ON');
console.log('');
let isBuilding = false;
function buildPackage() {
if (isBuilding) {
console.log('ā³ Build already in progress, skipping...');
return;
}
isBuilding = true;
console.log('šØ Building package...');
exec('yarn build', (error, stdout, stderr) => {
isBuilding = false;
if (error) {
console.error('ā Build failed:', error);
return;
}
console.log('ā
Package built successfully!');
console.log('š” Restart your Next.js dev server to see changes');
console.log('');
});
}
// Watch src directory for changes
const srcDir = path.join(__dirname, 'src');
if (fs.existsSync(srcDir)) {
fs.watch(srcDir, { recursive: true }, (eventType, filename) => {
if (filename && (filename.endsWith('.ts') || filename.endsWith('.tsx') || filename.endsWith('.css') || filename.endsWith('.scss'))) {
console.log(`š File changed: ${filename}`);
setTimeout(buildPackage, 500); // Debounce builds
}
});
} else {
console.log('ā ļø src/ directory not found. Make sure you run this from the kupos-ui-components directory.');
}
// Initial build
buildPackage();
// Keep the process running
process.on('SIGINT', () => {
console.log('\nš Stopping watch mode...');
process.exit(0);
});