Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
nuxt-svg-loader
Advanced tools
[![npm (scoped with tag)](https://img.shields.io/npm/v/nuxt-svg-loader/latest.svg?style=flat-square)](https://npmjs.com/package/nuxt-svg-loader) [![npm](https://img.shields.io/npm/dt/nuxt-svg-loader.svg?style=flat-square)](https://npmjs.com/package/nuxt-s
A live demo is available through the CodeSandBox of the repo.
nuxt-svg-loader
as a dependency using yarn or npm to your projectnuxt-svg-loader
to modules
section of nuxt.config.js
{
modules: [
'nuxt-svg-loader',
]
}
?inline
at the end of the file path<template>
<nav>
<a href="https://github.com/vuejs/vue">
<VueLogo />
Vue
</a>
<a href="https://github.com/svg/svgo">
<SVGOLogo />
SVGO
</a>
<a href="https://github.com/webpack/webpack">
<WebpackLogo />
webpack
</a>
<!-- Inline svg -->
<a class="with-background-svg" href="https://github.com/webpack/webpack">
webpack
</a>
<a href="https://github.com/webpack/webpack">
<img src="../components/NuxtTwo.svg?inline">
webpack>
</a>
</nav>
</template>
<script>
import VueLogo from '@/assets/svg/vue.svg';
import SVGOLogo from '@/assets/svg/svgo.svg';
import WebpackLogo from '@/assets/svg/webpack.svg';
export default {
name: 'Example',
components: {
VueLogo,
SVGOLogo,
WebpackLogo,
}
};
</script>
<style>
.with-background-svg {
background: url('@/assets/svg/vue.svg?inline')
}
</style>
The plugin will work seamlessly out of the box. It will also include SVGO defaults to avoid collisions between your optimized SVG files!
If you want to configure the underlying loader (or SVGO), you can do that easily as well. (All options available here)
// file: nuxt.config.js
export default {
// ...
// Your loader options as svgLoader object
svgLoader: {
svgoConfig: {
plugins: [
{ prefixIds: false } // Disables prefixing for SVG IDs
]
}
}
}
svgo
to svgoConfig
export default {
svgLoader: {
svgo: { //Rename to svgoConfig
plugins: [
{ prefixIds: true } // Delete that line (or the whole svgLoader object if you don't have any other configurations)
]
}
}
}
If you turn on Eslint on save by server, you should exclude .svg
files of eslint-loader
.
Example:
// nuxt.config.js
build: {
extend(config, ctx) {
// Run ESLint on save
if (ctx.isDev && ctx.isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)|(\.svg$)/ /* <--- here */
})
}
}
}
yarn install
or npm install
npm run dev
Copyright (c) Alexander Lichter
FAQs
[![npm (scoped with tag)](https://img.shields.io/npm/v/nuxt-svg-loader/latest.svg?style=flat-square)](https://npmjs.com/package/nuxt-svg-loader) [![npm](https://img.shields.io/npm/dt/nuxt-svg-loader.svg?style=flat-square)](https://npmjs.com/package/nuxt-s
The npm package nuxt-svg-loader receives a total of 3,819 weekly downloads. As such, nuxt-svg-loader popularity was classified as popular.
We found that nuxt-svg-loader 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.