Socket
Book a DemoInstallSign in
Socket

gatsby-transformer-svg-sprites

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-transformer-svg-sprites

Gatsby plugin to generate SVG sprites from GraphQL sources

5.0.1
latest
Source
npmnpm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-transformer-svg-sprites npm

Gatsby plugin to generate SVG sprites from GraphQL sources.

Installation

npm install gatsby-transformer-svg-sprites

Usage

/* gatsby-config.js */

module.exports = {
  plugins: [
    {
      resolve: 'gatsby-transformer-svg-sprites',
      options: {
        /* gatsby-transformer-svg-sprites options here */
      }
    }
  ]
}

GraphQL / JavaScript example

import { graphql } from 'gatsby'
import React from 'react'

const Page = ({ data }) => (
  <>
    {data.allFile.nodes.map(node => {
      const svg = node.childSvgSprites

      return svg && (
        <svg key={svg.url} viewBox={svg.viewBox}>
          <use xlinkHref={svg.url}/>
        </svg>
      )
    })}
  </>
)

export default Page

export const query = graphql`
  query {
    allFile {
      nodes {
        childSvgSprites {
          url
          viewBox
        }
      }
    }
  }
`

Options

optimize

Type: boolean. Default: process.env.NODE_ENV === 'production'.

Defines if the sprites file should be minified. By default, it is enabled on production environments.

skip

Type: string or Array. Default: ''.

A path or an array of paths that shouldn't be included in the sprites file. It supports glob patterns.

SVG Mixer options

Any other option passed to gatsby-transformer-svg-sprites will be passed to svg-mixer — more info about its options can be found here.

License

The MIT License

Keywords

gatsby

FAQs

Package last updated on 10 Mar 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.