Gathering detailed insights and metrics for svg-classic-sprite-loader
Gathering detailed insights and metrics for svg-classic-sprite-loader
npm install svg-classic-sprite-loader
Typescript
Module System
Node Version
NPM Version
49.5
Supply Chain
89.5
Quality
67.7
Maintenance
25
Vulnerability
97
License
JavaScript (56.06%)
CSS (26.36%)
HTML (17.59%)
Total Downloads
17,877
Last Day
1
Last Week
13
Last Month
119
Last Year
3,389
1 Stars
49 Commits
5 Watching
5 Branches
7 Contributors
Minified
Minified + Gzipped
Latest Version
0.2.5
Package Id
svg-classic-sprite-loader@0.2.5
Unpacked Size
55.42 kB
Size
15.87 kB
File Count
39
NPM Version
6.10.2
Node Version
8.11.4
Cumulative downloads
Total Downloads
Last day
-91.7%
1
Compared to previous day
Last week
-67.5%
13
Compared to previous week
Last month
-2.5%
119
Compared to previous month
Last year
-48.4%
3,389
Compared to previous year
Webpack loader for creating classic SVG sprites.
The main reason we make a different loader from svg-sprite-loader is that non-classic way (not using background-position
) to create svg sprite does not work in Safari.
This article shows several ways to create svg sprites. You can take a look in different browers.
1npm install --save-dev svg-classic-sprite-loader
Note: This loader does not support Webpack@4.x currently.
Add loader
in webpack.config.js
like this:
1module.exports = { 2 ... 3 module: { 4 rules: [ 5 { test: /\.css$/, use: [ 6 'style-loader', 7 'css-loader', 8 'svg-classic-sprite-loader', 9 ] }, 10 { test: /\.svg$/, use: { 11 loader: 'file-loader', 12 options: { 13 name: '[name].[ext]' 14 } 15 } }, 16 ], 17 }, 18};
Use svgs in a CSS file:
1.foo { 2 background: url(./assets/check.svg); 3} 4.bar { 5 background: url(./assets/accessory.svg); 6}
The loader will merge svgs into a sprite file, and replace CSS codes:
1.foo { 2 background: url(sprite.svg) -20px -20px no-repeat; 3} 4.bar { 5 background: url(sprite.svg) -92px -20px no-repeat; 6}
For more examples, check here.
string
'sprite'
Default file name of sprite output file.
number
'sprite'
The margin between svgs in sprite.
string
'all'
Options: 'all'
、'query'
、RegExp
How to filter svg files for merging:
'all'
: All imported svgs will be merged.'query'
: Only svg path with ?sprite
query param will be merged.RegExp
: Only svg path matched by RegExpCustomize key of query param in svg path. Only works when filter: 'query'
string
'sprite'
1/* webpack.config.js */ 2loader: 'svg-classic-sprite-loader', 3options: { 4 filter: 'query', 5},
1/* css */ 2.test { 3 background: url(./assets/log-check.svg?sprite); 4} 5.test1 { 6 background: url(./assets/check.svg?sprite=sprite); 7} 8.test2 { 9 background: url(./assets/apm-check.svg); 10}
log-check.svg
and check.svg
are merged into sprite.svg
. Finally output files are sprite.svg
and apm-check.svg
.
1.foo { 2 background: url(./assets/check.svg?sprite=sprite1); 3} 4.bar { 5 background: url(./assets/accessory.svg?sprite=sprite2); 6} 7...
check.svg
is merged into sprite1.svg
, and accessory.svg
is merged into sprite2
. Finally output files are sprite1.svg
and sprite2.svg
.
1/* webpack.config.js */ 2loader: 'svg-classic-sprite-loader', 3options: { 4 filter: /log/, 5},
1/* css */ 2.test{ 3 background: url(./assets/log-check.svg?sprite=sprite1); 4} 5.test1{ 6 background: url(./assets/check.svg?sprite=sprite1); 7}
Only log-check.svg
is merged into sprite1.svg
. Finally output files are sprite1.svg
and check.svg
.
See Releases
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More