Update method for handling SVGs via webpack #45
Merged
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.
Description
Fixes #34. This PR updates the way that SVGs are processed via Webpack, following the methods outlined in the SVGR documentation related to handling both SVG and SVGR components in the same project.
With this change, SVGs are processed differently depending on whether you include
?url
as aresourceQuery
on the end of your import file path.If
?url
is present, the SVG will be processed as an asset (file or dataURI depending on file size), otherwise it will run through SVGR and be converted into a React component.The previous method could handle both import types, but there are a few benefits in making this change:
babel-loader
is not required when using@svgr/webpack
(source)url-loader
is being deprecated in favour of asset modules (source)This PR introduces a breaking change as existing SVG imports would need to be updated from:
to:
How has this been tested?