Comments (15)
The src
option supports globbing, which also supports something like (a|b)
for ORs, or use sets using curly braces.
Either that or you could add two seperate instances of the plugin to your plugins array in your configuration if you want two seperate SVGs as output.
Let me know!
from svg-spritemap-webpack-plugin.
@ctkc, any updates on this?
from svg-spritemap-webpack-plugin.
I wanted merge two different inputs into the same output file. If I put two instances of the same plugin with the same output, the second instance override the file so it is not what I need but thank you very much for your answer and sorry for the delay.
from svg-spritemap-webpack-plugin.
If you're still trying to do that, it's possible to do this through globbing, something like the following should work:
{
src: '{path/to/one/directory,path/to/another/directory}/**/*.svg'
// ...
}
If you need any more info; this glob primer explains it pretty well.
Update: 2.4.0
supports arrays for the src
option.
from svg-spritemap-webpack-plugin.
It works!. Thank you so much!
from svg-spritemap-webpack-plugin.
Great! No problem at all! 😄
from svg-spritemap-webpack-plugin.
For anyone looking for this feature, 2.4.0
has just been released which adds array support to the src
option.
The example I posted in #13 (comment) could be rewritten like this:
{
src: [
'path/to/one/directory/**/*.svg',
'path/to/another/directory/**/*.svg'
]
// ...
}
from svg-spritemap-webpack-plugin.
Hello @cascornelissen relateted to this! IF I have SVGs grouped into folders for each page and I want to create one Sprite for each page, u recommend to do it with multiple separate instances?
I guess that's the way to go, thanks in advance
from svg-spritemap-webpack-plugin.
Yeah, if you want to create separate spritemaps then multiple instances would be the way to go 😉
from svg-spritemap-webpack-plugin.
@cascornelissen hey sorry, another questions, how can I make the Id value the same as the svg element that gets into the sprite?
Right now I have flags and I would like to use them by the locale like en, es, fr for the IDs, and the plugin assigns numbers to the Sprites. Do you have an advice about this? I'm in 1.2.0 because my webpack version is not the last one
from svg-spritemap-webpack-plugin.
Just providing more info: The files that are in the folder, have the locale name like en.svg es.svg etc and I would like to preserve it for the IDs
from svg-spritemap-webpack-plugin.
By default the id is the svg files name, if you want to have separate sprites per locale you can use the prefix similar to what I've done here, this way you can have a directory per locale.
from svg-spritemap-webpack-plugin.
@gabolecointere, I'm afraid you'll have to update to the latest major version for this.
from svg-spritemap-webpack-plugin.
I just upgraded and I have two issues: npm run dev and watch produces the build but npm run prod returns an issue like: Unknown Word
When the build runs with npm run dev, my sprites.svg file it's empty :( This is my webpack config:
plugins: [ new CopyWebpackPlugin([{ from: 'resources/assets/img', to: 'img', // Laravel mix will place this in 'public/img' }]), new ImageminPlugin({ test: /\.(jpe?g|png|gif|svg)$/i, plugins: [ imageminMozjpeg({ quality: 80, }) ] }), new SVGSpritemapPlugin('resources/assets/img/header/round-flags/*.svg', { output: { filename: 'img/sprites.svg', chunk: { name: 'img/spritemap', keep: true } } }) ]
from svg-spritemap-webpack-plugin.
@gabolecointere, can you create a new (well-formatted) issue with a minimal test case that fails for you?
from svg-spritemap-webpack-plugin.
Related Issues (20)
- <symbol> id is mangled by SVGO but not the css url anchor #fragment HOT 4
- contenthash not replacing on watch HOT 7
- Question, how generate json file with all file names HOT 3
- Provide option to add custom attributes to SVG element. HOT 2
- Cannot disable individual SVGO plugins. HOT 3
- Module not found: Error: Can't resolve './spritemap.svg' in src HOT 5
- SVG's not scaling with Webpack 5 HOT 7
- Google chrome ignoring <mask> HOT 4
- Glob doesn't find anything on windows HOT 5
- webpack dev server support HOT 8
- Generated SVG is not added to spritemap chunk HOT 7
- version 4.4.1 not compiling HOT 10
- Windows pattern HOT 4
- Rebuilds every time editing js files in watch mode. HOT 4
- Problem with path.join on windows HOT 2
- (node:19636) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'trim' of undefined HOT 1
- 404 Error when `options.output` changed
- Preserve svg with styles attribute HOT 7
- Empty output file when the style attribute contains either "visibility: hidden" or "display: none" HOT 3
- Add `mask` support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg-spritemap-webpack-plugin.