We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import { defineConfig, type Plugin } from "vite"; import { extname } from "node:path"; // convert svg to jsx function svg(): Plugin { return { name: "svg", async transform(code, id) { if (extname(id) === ".svg") { return this.transformJsxOrTs( `export default () => ${decodeURIComponent(code) .replace('export default "data:image/svg+xml,', "") .replace('"', "")}` ); } }, }; }
ability to run vite's internal transformer with all the user's plugins
No response
The text was updated successfully, but these errors were encountered:
You can achieve this by using a virtual module. Related: rollup/rollup#5903
import { defineConfig, type Plugin } from "vite"; import { extname } from "node:path"; // convert svg to jsx function svg(): Plugin { return { name: "svg", resolveId() { /* TODO: impl */ }, load() { /* TODO: impl */ }, async transform(code, id) { if (id.includes('custom-svg')) { return `export default () => ${decodeURIComponent(code) .replace('export default "data:image/svg+xml,', "") .replace('"', "")}` } if (extname(id) === ".svg") { return `export { default } from ${JSON.stringify(`\0${id}?custom-svg&ext=.jsx`)}` } }, }; }
Sorry, something went wrong.
No branches or pull requests
Description
Suggested solution
ability to run vite's internal transformer with all the user's plugins
Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: