Skip to content
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

svg-sprite-loader not working in nuxt.js application #185

Closed
unwrittenmike opened this issue Aug 30, 2017 · 18 comments
Closed

svg-sprite-loader not working in nuxt.js application #185

unwrittenmike opened this issue Aug 30, 2017 · 18 comments

Comments

@unwrittenmike
Copy link

Do you want to request a feature, report a bug or ask a question?
Report a bug
What is the current behavior?
Compiled with 1 warnings
warning in ./assets/icons/big-loader.svg
svg-sprite-loader exception. 2 rules applies to
What is the expected behavior?
No warnings and sprite to load
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.
config.module.rules.push({ test: /\.svg$/, loader: 'svg-sprite-loader' })

import test from '~/assets/icons/big-loader.svg'

Please tell us a
bout your environment:

  • Node.js version: v8.1.4
  • webpack version: 3.5.5
  • svg-sprite-loader version: 3.2.4
  • OS type & version: ? MasOs 10.12.6

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

@kisenka
Copy link
Contributor

kisenka commented Aug 31, 2017

I need the whole webpack config to be sure that is a loader bug

@unwrittenmike
Copy link
Author

unwrittenmike commented Aug 31, 2017 via email

@unwrittenmike
Copy link
Author

That a nuxt.js config...

@vanoorschot
Copy link

@unwrittenmike You can extend the nuxt default webpack in the nuxt.config.js.
Nuxt already has it's own webpack config (https://nuxtjs.org/guide/assets/#webpacked) which uses the 'url-loader' for svg files.
I don't think this is a bug in svg-sprite-loader, but a conflict with the nuxt webpack configuration.

Right now I have the same problem ;)

@vanoorschot
Copy link

@unwrittenmike I created an issue with Nuxt, to ask how this can be achieved.
Meanwhile I wrote a hack to get it working.

See my ticket for the implementation:
nuxt/nuxt#1584

@unwrittenmike
Copy link
Author

@vanoorschot Thanks! Your hack works for me! ... sat for a a full day trying to get this working.. total legend!

@kisenka Sorry for pointing the blame at your library...

@jesperlandberg
Copy link

Is there a chance someone could show me a full implementation/solution to this? How the config looks and how the icon is imported into the components because I can't seem to get this working. Would be extremely grateful.

@unwrittenmike
Copy link
Author

@jesperlandberg I'll post a link to some code for you a bit later today. I have it running smoothly in 2 nuxt.js apps ;)

@jesperlandberg
Copy link

@unwrittenmike would be awesome=)

@unwrittenmike
Copy link
Author

@unwrittenmike
Copy link
Author

@jesperlandberg Happy to answer any questions you may have...

@jesperlandberg
Copy link

@unwrittenmike awesome! Looks like the repo doesnt exist tho?

@unwrittenmike
Copy link
Author

@jesperlandberg try this, sorry new to sharing repos... not the hottest git guy haha... https://bitbucket.org/unwrittenmike/spriteloadertest

@jesperlandberg
Copy link

@unwrittenmike thanks a lot! However, the icons doesn't seem to show up. Tested on my project and also cloning ur repo and running dev mode.

icons

@krivaten
Copy link

@jesperlandberg any chance you could make a gist or something? Both the BitBucket links were busted :(

@ChucKN0risK
Copy link

ChucKN0risK commented Nov 1, 2018

@unwrittenmike The link you provided doesn't work anymore.

@jesperlandberg I agree with @krivaten. I would be glad if you could make a gist 😉

@ChucKN0risK
Copy link

@unwrittenmike @jesperlandberg @krivaten I managed to deal with SVG sprite with the following configuration. I hope it will help you 😉

https://gist.github.com/ChucKN0risK/2d0f8466e13d4b63f3982ed2b60bd111

@dword-design
Copy link

I actually wrote a Nuxt module that does it. Maybe it's still of interest:
https://www.npmjs.com/package/nuxt-svg-sprite-loader

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

No branches or pull requests

7 participants