Gathering detailed insights and metrics for svg-mixed-loader
Gathering detailed insights and metrics for svg-mixed-loader
npm install svg-mixed-loader
Typescript
Module System
Node Version
NPM Version
55.1
Supply Chain
62.6
Quality
73.2
Maintenance
50
Vulnerability
98.6
License
JavaScript (100%)
Total Downloads
11,515
Last Day
18
Last Week
47
Last Month
270
Last Year
3,178
7 Stars
14 Commits
12 Watching
1 Branches
3 Contributors
Minified
Minified + Gzipped
Latest Version
0.8.3
Package Id
svg-mixed-loader@0.8.3
Unpacked Size
21.95 kB
Size
7.61 kB
File Count
17
NPM Version
7.0.10
Node Version
15.2.0
Cumulative downloads
Total Downloads
Last day
0%
18
Compared to previous day
Last week
-52%
47
Compared to previous week
Last month
15.4%
270
Compared to previous month
Last year
-12.5%
3,178
Compared to previous year
Webpack loader resolving svg into url string and multiple component formats.
In community svg files are commonly used to introduce icons to web apps, in this case developers are tend to import and svg as a component:
1import IconPlus from './icon-plus.svg'; 2 3const CreateButton = () => ( 4 <Button> 5 <IconPlus /> 6 Create New 7 </Button> 8);
Also, svg, when itself is a common image format, may used as an image:
1import logoURL from './logo.svg'; 2 3const Header = () => ( 4 <div style={{display: 'flex'}}> 5 <img width={180} height={30} src={logoURL} /> 6 <div style={{flex: 1}}> 7 {/* navigation}*/} 8 </div> 9 </div> 10);
As these use cases are conflicting to each other, this loader sovles this by export multiple possible formats from an svg file.
svg-mixed-loader
requires url-loader and file-loader as peer dependencies.
1npm install -D svg-mixed-loader url-loader file-loader
1// webpack.config.js 2module.exports = { 3 module: { 4 rules: [ 5 { 6 test: /\.svg$/, 7 use: [ 8 { 9 loader: 'svg-mixed-loader', 10 options: { 11 // options 12 }, 13 }, 14 // You may add other preprocess loaders like svgo-loader or img-loader here 15 ], 16 }, 17 ], 18 }, 19};
This loader currently create a default export of image URL, and a named export ReactComponent
as a react component.
1import React from 'react'; 2 3export default 'data:image/svg;...'; 4 5export const ReactComponent = props => React.createElement(/* ... */); 6ReactComponent.displayName = 'AutoResolvedComponentName';
1{ 2 // This option will be forwarded to url-loader, can set to false to disable generation of default export 3 url: { 4 limit: 1024, 5 }, 6 // Can be: 7 // 8 // 1. true: generate react component as ReactComponent named export with default option 9 // 2. false: don't generate react component 10 // 3. object: customize react code generation, see below 11 // 12 // Default to false. 13 react: { 14 // Can be multiple formats: 15 // 16 // 1. true: auto resolve a component name from resource path 17 // 2. false: remove display name from output 18 // 3. string: a static display name 19 // 4. function: customize display by (resourcePath) => string 20 // 21 // Default to true. 22 displayName: true, 23 } 24}
By default svg-mixed-loader
generates only default export, behaves exactly the same as url-loader
,
if ReactComponent
named export is wanted, pass {react: true}
as options is a quick solution.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/14 approved changesets -- score normalized to 0
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
Reason
41 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
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