
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@aidol/svg-icon
Advanced tools
A Vue SVG Symbol icon component for svg-sprite-loader, Easy to custom SVG icon 's color and size!!!
WARNING: This Package is no longer maintained, Please use vue-symbol-icon instead.
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.
font-size
and color
.# pnpm
$ pnpm add @aidol/svg-icon
# yarn
$ yarn add @aidol/svg-icon
# npm
$ npm i @aidol/svg-icon
demo.vue
<template>
<svg-icon icon-class="svg-symbol-id" font-size="36px" color="red" />
</template>
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 |
Vue CLI
webpack
with chainWebpack
:// vue.config.js
const path = require('path')
function resolve(dir) {
return path.join(__dirname, dir)
}
module.exports = {
// ...
chainWebpack(config) {
// Change the configuration of url-loader so that it does not process svg files used as icons in the specified folder
config.module
.rule("svg")
.exclude.add(resolve("src/icons"))
.end();
// Add svg-sprite-loader to process svg files in the specified folder
config.module
.rule("icons")
.test(/\.svg$/)
.include.add(resolve("src/icons"))
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: "icon-[name]"
})
.end();
}
}
Then, place your .svg
icon files in the src/icons/svg
folder.
Defines the entry point for batch importing .svg
modules:
// src/icons/index.js
import Vue from 'vue'
import SvgIcon from '@aidol/svg-icon' // svg component
// 1. register globally
Vue.component('svg-icon', SvgIcon)
// 2. require svg files
const req = require.context('./svg', false, /\.svg$/)
const requireAll = requireContext => requireContext.keys().forEach(requireContext)
requireAll(req)
.svg
files are centrally imported in the project entry file main.js
.import Vue from 'vue'
import '@/icons'
new Vue({
// ...
})
webpack
in the nuxt.config.js
:// nuxt.config.js
export default {
// ...
// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {
/*
** You can extend webpack config here
*/
extend(config, { isClient }) {
if (isClient) {
const svgRule = config.module.rules.find((rule) =>
rule.test.test('.svg')
)
svgRule.exclude = [resolve('assets/icons/svg')]
// Includes /assets/icons/svg for svg-sprite-loader
config.module.rules.push({
test: /\.svg$/,
include: [resolve('assets/icons/svg')],
loader: 'svg-sprite-loader',
options: {
symbolId: 'icon-[name]',
},
})
}
},
}
// ...
}
Centralize your *.svg
icon files in the ~/assets/icons/svg
folder.
Create a new ~/plugins/svg-icon.js
file and write in it:
import Vue from 'vue'
import SvgIcon from '@aidol/svg-icon' // svg component
// 1. register globally
Vue.component('svg-icon', SvgIcon)
// 2. require svg files
const req = require.context('~/assets/icons/svg', false, /\.svg$/)
const requireAll = (requireContext) => requireContext.keys().forEach(requireContext)
requireAll(req)
nuxt.config.js
:export default {
// ...
plugins: [
// ...
{ src: '~/plugins/svg-icon', mode: 'client' }
]
// ...
}
FAQs
A Vue SVG Symbol icon component for svg-sprite-loader, Easy to custom SVG icon 's color and size!!!
We found that @aidol/svg-icon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.