-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
113 lines (98 loc) · 3.41 KB
/
Copy pathbuild.js
File metadata and controls
113 lines (98 loc) · 3.41 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/usr/bin/env node
/**
* Zephyr Framework — Build Script
* Minifies JS and CSS using esbuild.
* Run: node build.js
*/
const { build } = require('esbuild');
const { readFileSync } = require('fs');
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
async function run() {
// Minify framework JS
await build({
entryPoints: ['zephyr-framework.js'],
outfile: 'zephyr-framework.min.js',
minify: true,
banner: { js: `/* Zephyr Framework v${pkg.version} | MIT License */` },
});
// Minify agent widget JS
await build({
entryPoints: ['zephyr-agent-widget.js'],
outfile: 'zephyr-agent-widget.min.js',
minify: true,
banner: { js: `/* Zephyr Agent Widget v${pkg.version} | MIT License */` },
});
// Minify WebMCP adapter JS
await build({
entryPoints: ['zephyr-webmcp.js'],
outfile: 'zephyr-webmcp.min.js',
minify: true,
banner: { js: `/* Zephyr WebMCP Adapter v${pkg.version} | MIT License */` },
});
// Minify A2UI renderer JS
await build({
entryPoints: ['zephyr-a2ui.js'],
outfile: 'zephyr-a2ui.min.js',
minify: true,
banner: { js: `/* Zephyr A2UI Renderer v${pkg.version} | MIT License */` },
});
// Minify framework CSS
await build({
entryPoints: ['zephyr-framework.css'],
outfile: 'zephyr-framework.min.css',
minify: true,
banner: { css: `/* Zephyr Framework v${pkg.version} | MIT License */` },
});
// Minify dashboard add-on JS
await build({
entryPoints: ['dashboard/zephyr-dashboard.js'],
outfile: 'dashboard/zephyr-dashboard.min.js',
minify: true,
banner: { js: `/* Zephyr Dashboard v${pkg.version} | MIT License */` },
});
// Minify dashboard add-on CSS
await build({
entryPoints: ['dashboard/zephyr-dashboard.css'],
outfile: 'dashboard/zephyr-dashboard.min.css',
minify: true,
banner: { css: `/* Zephyr Dashboard v${pkg.version} | MIT License */` },
});
// Minify runtime add-on JS
await build({
entryPoints: ['runtime/zephyr-runtime.js'],
outfile: 'runtime/zephyr-runtime.min.js',
minify: true,
banner: { js: `/* Zephyr Runtime v${pkg.version} | MIT License */` },
});
// Minify runtime add-on CSS
await build({
entryPoints: ['runtime/zephyr-runtime.css'],
outfile: 'runtime/zephyr-runtime.min.css',
minify: true,
banner: { css: `/* Zephyr Runtime v${pkg.version} | MIT License */` },
});
// Report sizes
const files = [
['zephyr-framework.js', 'zephyr-framework.min.js'],
['zephyr-agent-widget.js', 'zephyr-agent-widget.min.js'],
['zephyr-webmcp.js', 'zephyr-webmcp.min.js'],
['zephyr-a2ui.js', 'zephyr-a2ui.min.js'],
['zephyr-framework.css', 'zephyr-framework.min.css'],
['dashboard/zephyr-dashboard.js', 'dashboard/zephyr-dashboard.min.js'],
['dashboard/zephyr-dashboard.css', 'dashboard/zephyr-dashboard.min.css'],
['runtime/zephyr-runtime.js', 'runtime/zephyr-runtime.min.js'],
['runtime/zephyr-runtime.css', 'runtime/zephyr-runtime.min.css'],
];
console.log('\nZephyr Framework — Build Complete\n');
for (const [src, min] of files) {
const srcSize = readFileSync(src).length;
const minSize = readFileSync(min).length;
const pct = ((1 - minSize / srcSize) * 100).toFixed(0);
console.log(` ${src.padEnd(30)} ${(srcSize / 1024).toFixed(1)}KB → ${(minSize / 1024).toFixed(1)}KB (${pct}% smaller)`);
}
console.log('');
}
run().catch((err) => {
console.error(err);
process.exit(1);
});