Skip to content

SVGs imported as component should not create build files #7941

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

Closed
silverwind opened this issue Nov 6, 2019 · 2 comments
Closed

SVGs imported as component should not create build files #7941

silverwind opened this issue Nov 6, 2019 · 2 comments

Comments

@silverwind
Copy link

Describe the bug

SVG files imported as ReactComponent result in unused files in build/static/media and corresponding entries in build/precache-manifest.*.js.

When SVGs are loaded as a component, it is probably never desirable to have these files built so they should be omitted to reduce build size.

Steps to reproduce

# create minimal app that loads a SVG component
npx create-react-app svgtest
cd svgtest
echo 'import {ReactComponent as logo} from "./logo.svg"' > src/index.js
yarn build

# see presence of SVGs in build files
ls build/static/media
cat build/precache-manifest.*.js

Notes

It's probably best to mark their a removal as a breaking change in case people rely on those files being present. Upgrade instructions should mention that SVG files are only built when they are loaded like a regular image, e.g. import logo from "./logo.svg".

@stale
Copy link

stale bot commented Dec 6, 2019

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

@stale stale bot added the stale label Dec 6, 2019
@stale
Copy link

stale bot commented Dec 11, 2019

This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.

@stale stale bot closed this as completed Dec 11, 2019
@lock lock bot locked and limited conversation to collaborators Dec 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant