-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-styles-js.mjs
More file actions
32 lines (27 loc) · 1.08 KB
/
build-styles-js.mjs
File metadata and controls
32 lines (27 loc) · 1.08 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
// ============================================================
// GlassKit – Build Script: glasskit-styles.js
//
// Reads the minified CSS and embeds it into a JS module
// that exports a ready-to-use CSSStyleSheet (Constructable Stylesheet)
// for use in Shadow DOM / Web Components.
//
// Usage: node build-styles-js.mjs
// ============================================================
import { readFileSync, writeFileSync } from 'fs';
const pkg = JSON.parse(readFileSync('package.json', 'utf-8'));
const css = readFileSync('glasskit.min.css', 'utf-8');
const output = [
`// GlassKit v${pkg.version} – Constructable Stylesheet`,
'// Auto-generated by build-styles-js.mjs – do not edit manually.',
'',
`const css = ${JSON.stringify(css)};`,
'',
'const glassSheet = new CSSStyleSheet();',
'glassSheet.replaceSync(css);',
'',
'export { glassSheet, css };',
'',
].join('\n');
writeFileSync('glasskit-styles.js', output);
const sizeKB = (Buffer.byteLength(output) / 1024).toFixed(1);
console.log('✅ glasskit-styles.js generated (v' + pkg.version + ', ' + sizeKB + ' KB)');