Installations
npm install @aidol/svg-icon
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.21.1
NPM Version
6.14.17
Score
57
Supply Chain
99
Quality
75.7
Maintenance
100
Vulnerability
100
License
Contributors
Unable to fetch Contributors
Languages
Vue (58.03%)
JavaScript (30.75%)
HTML (11.23%)
Developer
yisibell
Download Statistics
Total Downloads
4,819
Last Day
5
Last Week
10
Last Month
45
Last Year
496
GitHub Statistics
1 Stars
31 Commits
2 Watching
2 Branches
1 Contributors
Bundle Size
7.47 kB
Minified
3.14 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.1.4
Package Id
@aidol/svg-icon@2.1.4
Unpacked Size
66.61 kB
Size
13.22 kB
File Count
8
NPM Version
6.14.17
Node Version
14.21.1
Publised On
01 Mar 2023
Total Downloads
Cumulative downloads
Total Downloads
4,819
Last day
400%
5
Compared to previous day
Last week
42.9%
10
Compared to previous week
Last month
18.4%
45
Compared to previous month
Last year
-68.6%
496
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
1
WARNING: This Package is no longer maintained, Please use vue-symbol-icon instead.
@aidol/svg-icon
A Vue SVG Symbol icon component for svg-sprite-loader, Easy to custom SVG icon 's color
and size
!!!
TIPS:
@aidol/svg-icon
needs to be used in conjunction withsvg-sprite-loader
. So, please pre-install svg-sprite-loader and config it.
Features
- Ability to manipulate SVG icons. e.g. using
font-size
andcolor
. - Support Iconfont svg icons.
Installation
1# pnpm 2$ pnpm add @aidol/svg-icon 3 4# yarn 5$ yarn add @aidol/svg-icon 6 7# npm 8$ npm i @aidol/svg-icon
Usage
demo.vue
1<template> 2 <svg-icon icon-class="svg-symbol-id" font-size="36px" color="red" /> 3</template>
Properties
Prop name | Default value | Required | Description | Type |
---|---|---|---|---|
icon-class | undefined | true | SVG Symbol Id which is SVG filename in the SVG folder. | string |
className | undefined | false | Add Extra class name to SVG Element | string |
color | undefined | false | Define SVG color | string |
fontSize | undefined | false | Define SVG size | string |
How to config svg-sprite-loader ?
In Vue CLI
- First, you need config
webpack
withchainWebpack
:
1// vue.config.js 2const path = require('path') 3 4function resolve(dir) { 5 return path.join(__dirname, dir) 6} 7 8module.exports = { 9 // ... 10 chainWebpack(config) { 11 12 // Change the configuration of url-loader so that it does not process svg files used as icons in the specified folder 13 config.module 14 .rule("svg") 15 .exclude.add(resolve("src/icons")) 16 .end(); 17 18 // Add svg-sprite-loader to process svg files in the specified folder 19 config.module 20 .rule("icons") 21 .test(/\.svg$/) 22 .include.add(resolve("src/icons")) 23 .end() 24 .use("svg-sprite-loader") 25 .loader("svg-sprite-loader") 26 .options({ 27 symbolId: "icon-[name]" 28 }) 29 .end(); 30 } 31}
-
Then, place your
.svg
icon files in thesrc/icons/svg
folder. -
Defines the entry point for batch importing
.svg
modules:
1// src/icons/index.js 2 3import Vue from 'vue' 4import SvgIcon from '@aidol/svg-icon' // svg component 5 6// 1. register globally 7Vue.component('svg-icon', SvgIcon) 8 9// 2. require svg files 10const req = require.context('./svg', false, /\.svg$/) 11const requireAll = requireContext => requireContext.keys().forEach(requireContext) 12requireAll(req)
- Finally, these
.svg
files are centrally imported in the project entry filemain.js
.
1import Vue from 'vue' 2 3import '@/icons' 4 5new Vue({ 6 // ... 7})
In Nuxt2
- First, config
webpack
in thenuxt.config.js
:
1// nuxt.config.js 2 3export default { 4 // ... 5 // Build Configuration (https://go.nuxtjs.dev/config-build) 6 build: { 7 /* 8 ** You can extend webpack config here 9 */ 10 extend(config, { isClient }) { 11 if (isClient) { 12 const svgRule = config.module.rules.find((rule) => 13 rule.test.test('.svg') 14 ) 15 svgRule.exclude = [resolve('assets/icons/svg')] 16 17 // Includes /assets/icons/svg for svg-sprite-loader 18 config.module.rules.push({ 19 test: /\.svg$/, 20 include: [resolve('assets/icons/svg')], 21 loader: 'svg-sprite-loader', 22 options: { 23 symbolId: 'icon-[name]', 24 }, 25 }) 26 } 27 }, 28 } 29 // ... 30}
-
Centralize your
*.svg
icon files in the~/assets/icons/svg
folder. -
Create a new
~/plugins/svg-icon.js
file and write in it:
1import Vue from 'vue' 2import SvgIcon from '@aidol/svg-icon' // svg component 3 4// 1. register globally 5Vue.component('svg-icon', SvgIcon) 6 7// 2. require svg files 8const req = require.context('~/assets/icons/svg', false, /\.svg$/) 9const requireAll = (requireContext) => requireContext.keys().forEach(requireContext) 10requireAll(req)
- Configure the svg-icon plugin to
nuxt.config.js
:
1export default { 2 // ... 3 4 plugins: [ 5 // ... 6 { src: '~/plugins/svg-icon', mode: 'client' } 7 ] 8 9 // ... 10}
CHANGE LOG
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
26 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-5j4c-8p2g-v4jx
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
1.7
/10
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