SVGR support (React only)
Preview.js supports SVGR out of the box:
import { ReactComponent as Logo } from "./logo.svg";
If you want to use default imports instead (for example if you're using react-svg-loader
), you will need to add a dev dependency on @previewjs/plugin-react
and customise preview.config.js
:
// preview.config.js
const { reactFrameworkPlugin } = require("@previewjs/plugin-react");
/** @type {import("@previewjs/config").PreviewConfig} */
module.exports = {
frameworkPlugin: reactFrameworkPlugin.create({
svgr: {
componentName: "default",
},
}),
};