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

Have SVGO features enabled when running SVGR webpack plugin #9487

Closed
smithad15 opened this issue Mar 23, 2022 · 5 comments · Fixed by #23283
Closed

Have SVGO features enabled when running SVGR webpack plugin #9487

smithad15 opened this issue Mar 23, 2022 · 5 comments · Fixed by #23283
Assignees
Labels
outdated scope: react Issues related to React support for Nx type: feature

Comments

@smithad15
Copy link

Description

When importing SVGs as React components, the SVGR Webpack plugin is working fine and able to be configured through a standalone svgr.config.js file (or similar) as supported by the underlying tool. The issue however is that any options related to SVGO functionality do not work. It seems as if the SVGO step in the pipeline has been permanently disabled based on the React webpack config. Would it be possible to re-enable SVGO in the SVGR pipeline so that imported SVG components can be optimized however the end user wishes (either based on the plugin defaults or overridden through a separate config file)? I'm not sure why this would be disabled in the first place.

Motivation

Since SVGR is included in the build tooling, it would be most beneficial to be able to utilize all of its functionality as opposed to disabling a significant portion of its feature set.

Suggested Implementation

Remove the svgo: false config line in the React webpack config. End users would then be able to configure its operation (or disable it completely) through an external config file.

@smithad15 smithad15 changed the title Have SVGO features enabled when running SVGR webpack plug in Have SVGO features enabled when running SVGR webpack plugin Mar 23, 2022
@FrozenPandaz FrozenPandaz added the scope: react Issues related to React support for Nx label Mar 25, 2022
@skoob13
Copy link

skoob13 commented Aug 5, 2022

The same applies to the Next.js configuration. Is there any reason why svgo: false should be applied? There are a lot of SVG assets in our organization, so we had to patch the React and Next.js packages to enable svgo.

@jbean96
Copy link
Contributor

jbean96 commented Nov 22, 2022

Any thoughts or work on this? Would also like to configure some SVGO functionality, would seem pretty feasible to allow the configuration of SVGR in next.config instead of just true/false.

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Jul 31, 2023
@stephenwade
Copy link
Contributor

This is still an issue.

@github-actions github-actions bot removed the stale label Aug 1, 2023
ndcunningham added a commit that referenced this issue May 13, 2024
This PR adds the ability to now override our svg options by providing
them either using `NxReactWebpackPlugin` for react apps or `withNx` for
Next.js apps

```
new NxReactWebpackPlugin({
  svgr: {
    svgo: true,
    titleProp: true,
    ref: true,
  }
}),
  ```

This now gives you control on customizing how the svg is handled. Should you need to enable svgo you can provide the config using `svgr.config.js`

https://react-svgr.com/docs/options/#svgo

closes: #9487
FrozenPandaz pushed a commit that referenced this issue May 13, 2024
This PR adds the ability to now override our svg options by providing
them either using `NxReactWebpackPlugin` for react apps or `withNx` for
Next.js apps

```
new NxReactWebpackPlugin({
  svgr: {
    svgo: true,
    titleProp: true,
    ref: true,
  }
}),
  ```

This now gives you control on customizing how the svg is handled. Should you need to enable svgo you can provide the config using `svgr.config.js`

https://react-svgr.com/docs/options/#svgo

closes: #9487
(cherry picked from commit 9cd0b42)
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: react Issues related to React support for Nx type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants