-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
41 lines (35 loc) · 929 Bytes
/
dev.js
File metadata and controls
41 lines (35 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import chokidar from 'chokidar';
import { exec } from 'child_process';
import { promisify } from 'util';
import liveServer from 'live-server';
const run = promisify(exec);
async function rebuild() {
try {
console.log('🔄 Rebuilding...');
await run('node build.js');
await run('sass src/theme.scss dist/theme.css');
await run('cp dist/theme.css docs/theme.css');
console.log('✅ Build complete.\n');
} catch (err) {
console.error('❌ Build failed:', err.stderr || err);
}
}
// Initial build
await rebuild();
// Watch for changes in key folders
const watcher = chokidar.watch('.', {
ignored: ['node_modules', 'dist', 'docs', '.git'],
ignoreInitial: true,
persistent: true,
});
watcher.on('all', async (event, path) => {
console.log(`📁 ${event} ${path}`);
await rebuild();
});
// Serve docs folder
liveServer.start({
root: 'docs',
open: true,
wait: 100,
logLevel: 0,
});