feat: Modernize the visual card editor. (#2586)

This commit is contained in:
Dermot Duffy
2026-07-20 20:44:16 -07:00
committed by GitHub
parent e204ec183f
commit b6e1de5999
146 changed files with 8487 additions and 5992 deletions
+28
View File
@@ -0,0 +1,28 @@
import { readFileSync } from 'node:fs';
/**
* Rollup/Vite plugin: importing an SVG yields `{ path, viewBox }` extracted at
* build time, the shape a Home Assistant custom iconset serves. The SVG must
* be a single-path icon.
*
* @type {() => import('rollup').Plugin}
*/
export const svgPath = () => ({
name: 'svg-path',
// Vite: run before its builtin asset handling.
enforce: 'pre',
load(id) {
if (!id.endsWith('.svg')) {
return null;
}
const source = readFileSync(id, 'utf-8');
const path = / d="([^"]*)"/.exec(source)?.[1];
const viewBox = /viewBox="([^"]*)"/.exec(source)?.[1];
if (!path || !viewBox) {
throw new Error(`Imported SVG must have a path and viewBox: ${id}`);
}
return `export default ${JSON.stringify({ path, viewBox })};`;
},
});