vite-plugin-magical-svg
Version:
An all-in-one Vite plugin that magically makes working with SVGs and bundling them a breeze
24 lines (20 loc) • 600 B
JavaScript
import { forwardRef } from "preact/compat";
import { jsx } from "preact/jsx-runtime";
export var createSvg = /*#__NO_SIDE_EFFECTS__*/ (viewBox, width, height, symbol) => {
let node = jsx("use", { href: symbol });
return forwardRef((props, ref) => {
return jsx("svg", { ref, viewBox, width, height, ...props, children: node });
});
};
export var createSvgDEV = /*#__NO_SIDE_EFFECTS__*/ (viewBox, width, height, xml) => {
return forwardRef((props, ref) => {
return jsx("svg", {
ref,
viewBox,
width,
height,
...props,
dangerouslySetInnerHTML: { __html: xml },
});
});
};