question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SVG Files are not included in the dev bundle.

See original GitHub issue

Can you reproduce the problem with latest npm?

Yes

Description

SVG files fail to be included in the development bundle.

This occurs when the image is imported like so: import Logo from '../../common/img/logo.svg'; and used like so: <img src={Logo} />

Other image files (.png, .jpg, etc) render as expected, but SVG files never come through.

Expected behavior

SVG images should load as normal.

Actual behavior

Renders as a broken <img /> tag. When the URL to the image, as output by Webpack, is entered into the URL bar, it renders this error: “error on line 1 at column 1: Document is empty”.

Environment

Node version 7.9.0 NPM version 4.2.0 Windows 10 | Version 1703 | OS Build 15063.0 Google Chrome | 58.0.3029.81 (64-bit)

Reproducible Demo

Due to some time constraints, I can’t make a demo at the moment. If you can’t reproduce this issue let me know and I’ll try to get a demo up.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:26 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
Timercommented, May 5, 2017

I believe it’s worth noting that you do not need to eject to use Sass, you can read how to do that in our docs.

2reactions
chrisjpattycommented, May 5, 2017

@gaearon Sorry, forgot to paste it. Demo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack is generating a bundle file for every single SVG file
Use LimitChunkCountPlugin and set maxChunks: 1 : const webpack = require('webpack'); module.exports = { // ... plugins: [ new ...
Read more >
How to Load SVG with React and Webpack | Pluralsight
In this guide, we'll learn about Scalable Vector Graphics (SVG) and explore the standard way of importing SVG in a React Application bundled...
Read more >
SVG - Parcel
SVG is a vector-based 2D graphics format based on XML, with support for interactivity and animation. Parcel includes support for SVG as a...
Read more >
How to configure CSS and CSS modules in webpack
One of the first thing you need to configure in your webpack project is CSS. CSS is so fundamental to a web app...
Read more >
How to import SVG files in React Native using react-native-svg
Rendering SVGs in mobile apps is not as simple as on the web, where you can use ... cd SvgDemoApp npm i react-native-svg...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found