Skip to content

SVG files imported as React components should not end up in build directory #9167

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

Open
dominique-mueller opened this issue Jun 16, 2020 · 7 comments · May be fixed by #12646
Open

SVG files imported as React components should not end up in build directory #9167

dominique-mueller opened this issue Jun 16, 2020 · 7 comments · May be fixed by #12646

Comments

@dominique-mueller
Copy link

Intro

SVG files can be imported as React component, and thus inlined into the bundle, using the following syntax:

import { ReactComponent as MySvg } from '../../assets/icons/my-svg.svg'

Actual behaviour

Although inlined, the original SVG files will still be processed (by Webpack?) and end up

  • in the build/static/media folder
  • in the asset-manifest.json file

Overall, this isn't critical - it only means that unused files end up in the build folder. Nevertheless, it's a very confusing behaviour, developers might assume those files are being used or even that SVGs imported the way described above are not being inlined.

Expected behaviour

The expected behaviour is that inlined resources do not end up in the build folder, resulting in a smaller and clean build folder.

Related

@stale
Copy link

stale bot commented Jul 18, 2020

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 Jul 18, 2020
@dominique-mueller
Copy link
Author

Not stale.

@stale stale bot removed the stale label Jul 18, 2020
@stale
Copy link

stale bot commented Aug 22, 2020

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 Aug 22, 2020
@dominique-mueller
Copy link
Author

Not stale.

@stale stale bot removed the stale label Aug 24, 2020
@stale
Copy link

stale bot commented Oct 4, 2020

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 Oct 4, 2020
@dominique-mueller
Copy link
Author

Not stale.

@stale stale bot removed the stale label Oct 5, 2020
@Soberia
Copy link

Soberia commented Nov 28, 2020

Overall, this isn't critical

It's critical when using Service Worker. Because SVG files also included in self.__WB_MANIFEST value which contains URLs to precache. That means browsers will send requests to precache all these SVG files which don't need at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants