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.

SVGs Not Loading / vue-svg-loader

See original GitHub issue
  • Laravel Mix Version: 0.7.2
  • Node Version (node -v): 7.2.0
  • NPM Version (npm -v): 4.1.1
  • OS: OS Sierra

Description:

SVGs are getting dumped into the fonts folder. I’m using the vue-svg-loader package, and have this rule applied:

{
test: /\.svg$/,
loader: 'vue-svg-loader'
},

in my modules I’m using this: import IconCalendar from '../../../svg/menu circle grid.svg';

error:

[Vue warn]: Invalid Component definition: /fonts/menu circle grid.svg?3644f1f735844b4b08228cc5b11a4534 
(found in component <hey-select> at /Users/nathanaelmoody/Sites/heystack-app/assets/js/components/inputs/Select.vue)

Steps To Reproduce:

  1. install this: https://github.com/visualfanatic/vue-svg-loader
  2. add the rule
  3. try to reference an svg file

Side Question: is there a way to reference everything from the project root? So I don’t have to keep doing ../../../.

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:10

github_iconTop GitHub Comments

4reactions
rderimaycommented, Feb 16, 2017

Yes that would be fine, but we also want to be able to overwrite the standard loader/configs for a particular type of file. For example, I would like to use this for icon SVGs (not for font SVGs of course…):

{
	test: /\.svg$/,
	loaders: ['svg-sprite-loader?' + JSON.stringify({
		name: '[name]_[hash]',
		prefixize: true
		})]
}

Will you proposal be able to handle that as well? (Maybe it is already possible, but it seems that the standard mix webpack config is taking precedence over the webpackConfig.rules that I am writing.)

3reactions
novalevelcommented, Oct 19, 2017

I work this use inline:require.context(‘!svg-sprite-loader?{“symbolId”:“icon-[name]”}!./svg’, false, /.svg$/);

Read more comments on GitHub >

github_iconTop Results From Across the Web

Load svg using vue-svg-loader not working #7360 - GitHub
What I did in my case and it works is to remove from the regex the svg extension and then as you did...
Read more >
Storybook does not load SVGs in Components of Vue project
@liximomo's answer is almost correct. You should remove svg file from file-loader processing rule, but the rule search condition should be ...
Read more >
Using SVG and Vue.js: A complete guide - LogRocket Blog
This is a complete guide to using SVG with Vue, including practical examples and best practices to help you along the way.
Read more >
vue-svg-loader
This loader inlines the SVGs which enables you to style aspects like for example stroke/fill color. Optimized. Each SVG you import is optimized...
Read more >
Dealing with SVG icons in Vue + Vite - DEV Community ‍ ‍
Solution 1: Adding back require() ... Probably the easiest way to fix this is to use vite-plugin-require which adds support for require() to...
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