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.

Question: How can I set the input dir of my svg files

See original GitHub issue

I tried the native svg-sprite package for npm and I created this script inside my package.json:

"gen-sprite": "svg-sprite --css --css-render-css --css-example --dest=dist app/icons/*.svg",

so everything is fine with it, it goes into my app/icons/ dir and creates a sprite out of all my svg icons.

Now I wanted to use it with webpack and my config looks like this: https://pastebin.com/nwGtGEiv

The problem is that nothing happens when I call my webserver. In all of your examples I see a js file with this inside:

import twitterLogo from './logos/twitter.svg';

but I don’t have such file and I don’t need it. So my question is, what is the option to set a path to the input folder of my svg icons. I tried include, but same result, no sprite.svg at the end.

Regards

Chris

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kisenkacommented, Jul 10, 2017

If you need just to create a sprite from set of images put following code somewhere in your app sources:

var files = require.context('./icons', false, /\.svg$/);
files.keys().forEach(files);

This will scan icons dir and import every SVG file. In combination with extract mode it will create a separate sprite file.

1reaction
Chris2011commented, Jul 10, 2017

I use TS and maybe the @types/webpack-env module is outdated. When I add @types/webpack-env via npm i, I got this error: error TS2306: File 'MyProject/node_modules/@types/webpack-env/index.d.ts' is not a module. But anyway, this is not the problem of this ticket.

Read more comments on GitHub >

github_iconTop Results From Across the Web

With the SVG package, is it possible to set the output folder ...
Is there a way to tell the package to feed Inkscape an output path that matches the input file path? A sample of...
Read more >
How to add a SVG icon within an input?
So I have the placeholder with a string which currently just printing that string. I need to put the icons within that I...
Read more >
SVGs Made Simple 2: How to Upload SVG Cut Files to Cricut ...
Get the free SVGs Made Simple workbook #2 here: https://jennifermaker.com/svgs-made-simple-workbook-2This is video 2 of the SVGs Made Simple ...
Read more >
Adding vector graphics to the web - Learn web development
In this article we'll show you how to include one in your webpage. ... The SVG format allows us to create powerful vector...
Read more >
SVG Files: What They Are and How to Make One
Most browsers are designed to render, interpret, and display SVG files. To open a .svg file, launch your browser, then open the file...
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