-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
33 lines (31 loc) · 1.2 KB
/
build.js
File metadata and controls
33 lines (31 loc) · 1.2 KB
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
import path from 'node:path';
import fs from 'node:fs';
const folderArg = process.argv[2] || '.';
const targetFolder = path.resolve(folderArg);
const buildDir = path.join(targetFolder, 'build');
try {
if (fs.existsSync(buildDir)) {
fs.rmSync(buildDir, { recursive: true, force: true });
}
fs.mkdirSync(buildDir, { recursive: true });
const viewerDist = path.resolve('viewer', 'dist');
if (fs.existsSync(viewerDist)) {
fs.cpSync(viewerDist, buildDir, { recursive: true });
} else {
console.warn(`[Warning] Source folder not found: ${viewerDist}`);
}
const frameworks = ['react', 'vue', 'angular', 'svelte', 'vanillajs'];
for (const framework of frameworks) {
const targetFrameworkDir = path.join(buildDir, 'frameworks', framework, 'dist');
const sourceFrameworkDir = path.resolve('frameworks', framework, 'dist');
fs.mkdirSync(targetFrameworkDir, { recursive: true });
if (fs.existsSync(sourceFrameworkDir)) {
fs.cpSync(sourceFrameworkDir, targetFrameworkDir, { recursive: true });
} else {
console.warn(`[Warning] Source folder not found: ${sourceFrameworkDir}`);
}
}
} catch (error) {
console.error('\n[ERROR] An error occurred during file copying:', error.message);
process.exit(1);
}