How to automatically inject extracted svg file?
See original GitHub issueDo you want to request a feature, report a bug or ask a question? Question.
What is the current behavior? I’ve extracted the svg sprites into separate file and it works, but I still have to manually inject it, and to make it worse, on production, development and Storybook it has to be done on 3 different ways. I’m currently using svg-sprite-injector but it doesn’t work on Storybook.
What is the expected behavior? Generic way to automatically inject path to svg file into the app, so it can be cached.
The best way is to create repo with minimal setup to demonstrate a problem (package.json, webpack config and your code). package.json:
{
test: /\.svg$/,
include: [path.resolve(__dirname, '../src/assets/svg-icons')],
use: [
{
loader: 'svg-sprite-loader',
options: {
extract: true,
spriteFilename: 'icons.svg'
}
},
{
loader: 'svgo-loader',
options: svgoConfig,
},
],
},
Icon.vue where I’m injecting the svg sprites:
const svgSpriteInjector = require('svg-sprite-injector');
const svgFiles = require.context('@/assets/svg-icons', true, /\.svg$/);
svgFiles.keys().forEach(key => svgFiles(key));
svgSpriteInjector('icons.svg', {revision: 1});
Please tell us about your environment:
- Node.js version: 8.7.0
- webpack version: 3.8.1
- svg-sprite-loader version: 3.4.1
- OS type & version: Win 10
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:12 (5 by maintainers)
Top Results From Across the Web
How to unzip files to upload into Cricut Design Space
Click your files you want to add to your canvas. Then click insert images. How to upload SVG cut files into Cricut Design...
Read more >Extract data in svg file and store automatically in excel
suppose if there are 20 svg files with the same circuit components but with different component values, I need to extract the content...
Read more >How to extract svg as file from web page - Stack Overflow
15 Answers 15 · Copy the SVG code snippet, and paste it into a new HTML page. · Save the HTML page as...
Read more >The packages svg and svg-extract - TeXDoc
During the extraction process many files are generated for each SVG file extraction. So it's oftentimes desirable to automatically remove these temporary ...
Read more >Add multi-density vector graphics - Android Developers
Any auto-generated PNG and XML files corresponding to the deleted vector drawable are removed from the project and the drive. Delivering an app ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, I am having a similar issue with the
svg-sprite-loader
I am using storybook with vue jsMy webpack config looks like this:
I also check out the git repository from @folmert and the HTML for the SVG isn’t working.
Hi
JS code will change at every new release so if we want efficient cache we need to extract the sprite isn’t it ? It is not clear for me how to load this extracted sprit with webpack then.