Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
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
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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.