After exporting the asset, some level of optimisation is needed before using it in the app.
-
Navigate to SVG OMG
-
Choose 'Open SVG', select the file, and switch to the 'Code' tab
-
Select 'Prettify code' and 'Multipass' in global settings
-
Copy the following template and paste into
src/app/images/spritemap.svg
at an appropriate place:<symbol id="name-of-sprite" viewbox="0 0 20 20"> <title>Name of Sprite</title> <path> </symbol>
-
Back to SVG OMG, copy everything within
<svg>
-
Past the copied code in place of
<path>
in the template -
Rename
id
,title
and replace theviewbox
dimensions with the ones from the<svg>
tag in SVG OMG
The custom made SVG component (app/components/svg
) is required to use sprites from spritemap.svg
Import and call the component passing the name declared in id
above as the spritemapID
:
import SVG from 'app/components/svg';
...
<SVG spritemapID="name-of-sprite" />