Socket
Socket
Sign inDemoInstall

gatsby-transformer-svg-sprites

Package Overview
Dependencies
273
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gatsby-transformer-svg-sprites

Create SVG sprites from GraphQL sources


Version published
Weekly downloads
4
decreased by-60%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

gatsby-transformer-svg-sprites

Gatsby plugin for creating SVG sprites from GraphQL sources.

Install

$ npm install gatsby-transformer-svg-sprites

Configure

// gatsby-config.js

module.exports = {
  plugins: [
    {
      resolve: `gatsby-transformer-svg-sprites`,
      options: {
        optimize: process.env.NODE_ENV === 'production',
        skip: '',
        /* ...SVG Mixer options */
      },
    },
  ],
}

Options

options

Default: {}; Type: Object.

The options object is passed to SVG Mixer. More info about its configuration can be found here.

optimize

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

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

skip

Default: ''; Type: string or Array.

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

Usage

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
        }
      }
    }
  }
`

License

The MIT License

Keywords

FAQs

Last updated on 02 Aug 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc