-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
SVGR #72
Milestone
Comments
13 tasks
arcticicestudio
added a commit
that referenced
this issue
Dec 6, 2018
- gatsby-plugin-svgr (1) - @svgr/webpack (2) References: (1) https://www.npmjs.com/package/gatsby-plugin-svgr (2) https://www.npmjs.com/package/@svgr/webpack GH-72
arcticicestudio
added a commit
that referenced
this issue
Dec 6, 2018
All configurations for SVGR are set in the `svgr.config.js` file instead of passing them to the corresponding Gatsby plugin for the Webpack loader. - `expandProps` = `end` - ensure props are always spread (`{...props}`) last on the root `<svg>` element. - `ext` = `jsx` - use the JSX file extension for generated components. - `icon` = `false` - ensure the `width` and `height` props (hardcoded `1em` value) are not added. - `ref` = `true` - export components using React's `forwardRef` API to reference the underlying component and allow access to the root SVG element which is necessary for animations. - `svgo` = `false` - all SVG files in this project are already optimized with SVGO using the included `.svgo.yml` configuration. The configuration for SVGO is implemented in the `.svgo.yml` file that is also placed in the project root and will be picked up by SVGO automatically. GH-72
arcticicestudio
added a commit
that referenced
this issue
Dec 6, 2018
Merged
arcticicestudio
added a commit
that referenced
this issue
Dec 6, 2018
arcticicestudio
added a commit
that referenced
this issue
Dec 13, 2018
This commit adds some icons of the awesome "Eva Icons" (1) project and the official Nord logo as SVG components. They are loaded with the SVGR webpack loader added in #72. References: (1) https://akveo.github.io/eva-icons GH-64
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue documents the integration of SVGR which transforms SVG into ready to use React components. It is part of create-react-app and makes SVG integration into React projects easy.
Configuration
All configurations will be placed in a
svgr.config.js
file in the project root instead of passing them to the corresponding Gatsby plugin for the Webpack loader that is documented in the section below.expandProps
=end
— ensure props are always spread ({...props}
) last on the root<svg>
element.ext
=jsx
— use the JSX file extension for generated components.icon
=false
— ensure thewidth
andheight
props (hardcoded1em
value) are not added.ref
=true
— export components using React'sforwardRef
API to reference the underlying component and allow access to the root SVG element which is necessary for animations.svgo
=false
— all SVG files in this project are already optimized with SVGO using the included.svgo.yml
configuration.Webpack Loader
To directly import SVG's as React component the @svgr/webpack package will be used to simply integrate SVGR as Webpack plugin. It'll be added through the gatsby-plugin-svgr which adjusts the required Webpack configurations by adding the loader and removing the default
.svg
file loader.Tasks
gatsby-plugin-svgr
to the Gatsby configuration.The text was updated successfully, but these errors were encountered: