Bundle frontend with esbuild, serve fonts offline, fix dashboard
- Add esbuild bundling: JS (IIFE, minified, sourcemapped) and CSS into single dist/ files, replacing 15+ individual CSS links and CDN scripts - Bundle Chart.js and ELK.js from npm instead of CDN (fully offline) - Serve DM Sans and Orbitron fonts locally from static/fonts/ - Fix dashboard automation card stretching full width (max-width: 500px) - Fix time_of_day condition not localized in automation cards - Add Chrome browser tools context file for MCP testing workflow - Update frontend context with bundling docs and Chrome tools reference Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
43
server/esbuild.mjs
Normal file
43
server/esbuild.mjs
Normal file
@@ -0,0 +1,43 @@
|
||||
import * as esbuild from 'esbuild';
|
||||
|
||||
const srcDir = 'src/wled_controller/static';
|
||||
const outDir = `${srcDir}/dist`;
|
||||
|
||||
const watch = process.argv.includes('--watch');
|
||||
|
||||
/** @type {esbuild.BuildOptions} */
|
||||
const jsOpts = {
|
||||
entryPoints: [`${srcDir}/js/app.js`],
|
||||
bundle: true,
|
||||
format: 'iife',
|
||||
outfile: `${outDir}/app.bundle.js`,
|
||||
minify: true,
|
||||
sourcemap: true,
|
||||
target: ['es2020'],
|
||||
logLevel: 'info',
|
||||
};
|
||||
|
||||
/** @type {esbuild.BuildOptions} */
|
||||
const cssOpts = {
|
||||
entryPoints: [`${srcDir}/css/all.css`],
|
||||
bundle: true,
|
||||
outdir: outDir,
|
||||
outbase: `${srcDir}/css`,
|
||||
minify: true,
|
||||
sourcemap: true,
|
||||
logLevel: 'info',
|
||||
loader: { '.woff2': 'file' },
|
||||
assetNames: '[name]',
|
||||
entryNames: 'app.bundle',
|
||||
};
|
||||
|
||||
if (watch) {
|
||||
const jsCtx = await esbuild.context(jsOpts);
|
||||
const cssCtx = await esbuild.context(cssOpts);
|
||||
await jsCtx.watch();
|
||||
await cssCtx.watch();
|
||||
console.log('Watching for changes...');
|
||||
} else {
|
||||
await esbuild.build(jsOpts);
|
||||
await esbuild.build(cssOpts);
|
||||
}
|
||||
Reference in New Issue
Block a user