Build script minifies and base64-encodes the theme for telnet transfer. Outputs to settings-theme/dist/ (gitignored). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30 lines
937 B
JavaScript
30 lines
937 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const src = path.join(__dirname, 'com.palm.app.settings.js');
|
|
const code = fs.readFileSync(src, 'utf8');
|
|
|
|
let minified = code
|
|
.replace(/\/\/[^\n]*/g, '')
|
|
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
.replace(/\n\s*\n/g, '\n')
|
|
.replace(/^\s+/gm, '')
|
|
.replace(/\n/g, '')
|
|
.replace(/ +/g, ' ');
|
|
|
|
console.log('Original size:', code.length, 'bytes');
|
|
console.log('Minified size:', minified.length, 'bytes');
|
|
|
|
const outDir = path.join(__dirname, 'dist');
|
|
fs.mkdirSync(outDir, { recursive: true });
|
|
|
|
const outPath = path.join(outDir, 'com.palm.app.settings.min.js');
|
|
fs.writeFileSync(outPath, minified);
|
|
console.log('Written to:', outPath);
|
|
|
|
const b64 = Buffer.from(minified).toString('base64');
|
|
const b64Path = path.join(outDir, 'com.palm.app.settings.b64');
|
|
fs.writeFileSync(b64Path, b64);
|
|
console.log('Base64 size:', b64.length, 'bytes');
|
|
console.log('Base64 written to:', b64Path);
|