()
| 63 | } |
| 64 | |
| 65 | async function watch() { |
| 66 | console.log('Watching for changes...'); |
| 67 | |
| 68 | // Initial build |
| 69 | await build(); |
| 70 | |
| 71 | // Watch input files |
| 72 | for (const file of inputFiles) { |
| 73 | const filePath = path.join(rootDir, file); |
| 74 | fs.watch(filePath, async (eventType) => { |
| 75 | if (eventType === 'change') { |
| 76 | console.log(`\nFile changed: ${file}`); |
| 77 | await build(); |
| 78 | } |
| 79 | }); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | if (isWatch) { |
| 84 | watch().catch(console.error); |