This repository has been archived on 2026-04-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
core/src/editor/build.mjs
Jeffrey Smith 680ec3b897
All checks were successful
CI/CD / detect-changes (push) Successful in 3s
CI/CD / test-frontend (push) Successful in 5s
CI/CD / test-go-pg (push) Successful in 2m34s
CI/CD / test-sqlite (push) Successful in 2m46s
CI/CD / build-and-deploy (push) Successful in 1m55s
Feat rebrand armature (#43)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
2026-03-31 23:25:37 +00:00

55 lines
1.6 KiB
JavaScript

// ==========================================
// Armature — CM6 Build Script
// ==========================================
// Bundles CodeMirror 6 into a single IIFE that
// exposes window.CM. Run via scripts/build-editor.sh
// or directly: node build.mjs [--outdir=path]
//
// Output:
// codemirror.bundle.js (~295KB min, ~90KB gzip)
// codemirror.bundle.css (~5-10KB)
// ==========================================
import { build } from 'esbuild';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
// Parse --outdir=<path> from argv
let outdir = resolve(__dirname, 'dist');
for (const arg of process.argv.slice(2)) {
if (arg.startsWith('--outdir=')) {
outdir = resolve(arg.slice('--outdir='.length));
}
}
try {
const result = await build({
entryPoints: [resolve(__dirname, 'index.mjs')],
bundle: true,
minify: true,
format: 'iife',
target: ['es2020'],
outfile: resolve(outdir, 'codemirror.bundle.js'),
// Metafile for optional size analysis
metafile: true,
// Log level
logLevel: 'info',
});
// Print bundle size summary
if (result.metafile) {
const outputs = result.metafile.outputs;
for (const [file, info] of Object.entries(outputs)) {
const kb = (info.bytes / 1024).toFixed(1);
console.log(` ${file}: ${kb} KB`);
}
}
console.log(`✅ CM6 bundle → ${outdir}`);
} catch (err) {
console.error('❌ CM6 build failed:', err.message);
process.exit(1);
}