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 Sprite not working in CSS - [object Object]

See original GitHub issue

Do you want to request a feature, report a bug or ask a question? Report a bug

What is the current behavior? SCSS input: background: url('../../static/images/svg-sprites/caret-down.svg') no-repeat; CSS output: background: url(http://localhost:3000/[object Object]) no-repeat;

What is the expected behavior? SCSS input: background: url('../../static/images/svg-sprites/caret-down.svg') no-repeat; CSS output: background: url(http://localhost:3000/images/sprites.svg#caret-down) no-repeat;

If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code. Webpack config for SVG is simple:

{
	test: /static\/images\/svg-sprites\/.*\.svg$/,
	use: [
		{
			loader: 'svg-sprite-loader',
			options: {
				spriteFilename: 'images/sprites.svg'
			}
		},
		{
			loader: 'svgo-loader'
		}
	]
}

Importing SVG files in JS are working.

The best way is to create repo with minimal setup to demonstrate a problem (package.json, webpack config and your code). It you don’t want to create a repository - create a gist with multiple files https://gist.github.com/GrzegorzZajac000/86618bf29024a7b82e9fb7c0863b7c30 - base webpack config https://gist.github.com/GrzegorzZajac000/adb2a4888d1e64756a68e690460111b2 - dev webpack config

If this is a feature request, what is motivation or use case for changing the behavior?

Please tell us about your environment:

  • Node.js version: v8.6.0
  • webpack version: 3.5.5
  • svg-sprite-loader version: 3.5.1
  • OS type & version: MacOS High Sierra 10.13

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
kisenkacommented, Dec 12, 2017

@vitortalaia in your case it can be fixed by setting esModule: false in loader config:

{
        test: /\.svg$/,
        loader: 'svg-sprite-loader',
        include: resolve('src/assets/icons'),
        options: {
          extract: true,
          spriteFilename: utils.assetsPath('img/sprite-[hash:7].svg'),
          esModule: false
        }
      }
2reactions
MarkiyanPytscommented, Feb 1, 2019

Is there a resolution for background: url(…/…/C:/myApp/src/img/icn/arrw.svg);

issue ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SVG Sprite not working in CSS - [object Object] #225 - GitHub
svg ') no-repeat; CSS output: background: url(http://localhost:3000/[object Object]) no-repeat;. What is the expected behavior? SCSS input:
Read more >
SVG sprite with <object> - css - Stack Overflow
So I have a sprite SVG with lots of icons laid out in a grid like pattern (each has it's own 30 x...
Read more >
Cutup #5 Icons with CSS / SVG sprite | by nana Jeon - Medium
Today I would like to share with you how to implement icons in CSS in two ways, CSS sprite and SVG sprite. CSS...
Read more >
Icon System with SVG Sprites - CSS-Tricks
First let's cover how it works. A nice way to handle your icons is to have a folder full of .
Read more >
@twbs/svg-sprite - npm
Start using @twbs/svg-sprite in your project by running `npm i ... inline sprites using the <symbol> element; and SVG stacks.
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