SVGR support (React only)
Your code may rely on SVG files imported as React components, such as:
import { ReactComponent as Logo } from "./logo.svg";
In order to make this work, you will need to add a dev dependency on vite-plugin-react-svgr
(or any other SVGR plugin for Vite) and customise preview.config.js
:
// preview.config.js
import { defineConfig } from "@previewjs/config";
import { svgr } from "vite-plugin-react-svgr";
export default defineConfig({
vite: {
plugins: [
svgr({
exportAs: "ReactComponent",
// exportAs: "default" if you want `import Logo from "./logo.svg"` instead
// If you import SVG files via an alias, you'll need to also pass "alias" here.
// See https://previewjs.com/docs/config/aliases
//
// alias: { ... }
}),
],
},
});