Skip to content

create-react-app: Import SVG paths with default import #3825

@karlhorky

Description

@karlhorky

🐛 bug report

Description of the problem

In create-react-app I would like to be able to import SVG image paths using the syntax below:

import img from './img.svg'

This works in a normal create-react-app application.

In CodeSandbox it results in a broken image:

Screen Shot 2020-04-02 at 17 58 25

Alternatives I've Tried

I know that there is the ReactComponent named export from SVGs, which is great!

import { ReactComponent } from "./resources/calendar.svg";

But sometimes I want to import the paths to the SVGs instead.

How has this issue affected you? What are you trying to accomplish?

I would like to use SVGs with the paths instead of the ReactComponent.

Importing images from

Link to sandbox: link (optional)

Your Environment

Software Name/Version
Сodesandbox
Browser
Operating System

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions