Skip to content
New issue

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

svgo doesnt seem to be included correctly #108

Open
sirpy opened this issue Jan 31, 2024 · 0 comments
Open

svgo doesnt seem to be included correctly #108

sirpy opened this issue Jan 31, 2024 · 0 comments

Comments

@sirpy
Copy link

sirpy commented Jan 31, 2024

Switching to vite from webpack some of the svgs are broken.
I've looked at the svgr/webpack code and its config is plugins:[svgo,jsx] vs just jsx in vite.
Just adding svgo:true in options doesnt seem to do anything

It is fixed after modifying the code to:

const { default: svgo } = await import("@svgr/plugin-svgo");

                const filePath = id.replace(postfixRE, "");
                const svgCode = await fs.promises.readFile(filePath, "utf8");
                
                const componentCode = await transform(svgCode, svgrOptions, {
                    filePath,
                    caller: {
                        defaultPlugins: [svgo.default,jsx],
                    },
                });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant