fix: Added svgo as default plugin as long svgo is not false #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, thank you for creating this plugin.
I came to esbuild-plugin-svgr from @svgr/rollup and was happy that there allready exists an equivalent to the rollup version.
Unfortunately, I had the issue that esbuild-plugin-svgr does not behave like the official @svgr/rollup.
A lot of my SVGs looked wrong. This happened because the CSS classes of the SVGs clashed, and the styles got overwritten. I figured out that esbuild-plugin-svgr does not invoke the @svgr/plugin-svgo by default as the rollup plugin does. The svgo plugin would make the classes and IDs unique so that clashes can not happen.
Adding @svgr/plugin-svgo to the options in the esbuild config file is possible. But I think it would save a lot of work for people if the esbuild-plugin-svgr would behave the same as the official @svgr/rollup.
Here, you see that svgo should be true by default:
https://react-svgr.com/docs/options/#svgo
Here you see that the official @svgr/rollup plugin also has svgo set as default plugin:
https://github.com/gregberge/svgr/blob/main/packages/rollup/src/index.ts#L63
The svgo plugin needs to be before the jsx plugin. Therefore, I added it the way as you can see in the code.