Socket
Socket
Sign inDemoInstall

rollup-plugin-svg

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-svg

Import SVG images


Version published
Weekly downloads
27K
decreased by-15.77%
Maintainers
1
Weekly downloads
 
Created
Source

rollup-plugin-svg

Import SVG files as base64, or as Markup

CircleCI JavaScript Style Guide

Installation

npm i -D rollup-plugin-svg

Usage

// rollup.config.js
import svg from 'rollup-plugin-svg'

export default {
  entry: 'src/input.js',
  dest: 'dist/output.js',
  plugins: [
    svg()
  ]
}

You can then use svgs in your bundle thusly:

import logo from './desirable-objects.svg'

// Without base64:
document.body.appendChild( logo )

// With base64:
<img src="{logo}" alt="Whatever" />

Options:

base64

Defaults to false.

Bas64 encoded SVGs will be 33% larger than the size on disk. You should therefore only use this for small images where the convenience of having them available on startup (e.g. rendering immediately to a canvas without co-ordinating asynchronous loading of several images) outweighs the cost.

Sources

This plugin was built (based on the rollup-plugin-image plugin) because it appears that the two existing suitable plugins:

rollup-plugin-image rollup-plugin-url

don't seem to work any more. I wanted a simple solution to provide SVG images to Vudash

License

MIT

Keywords

FAQs

Package last updated on 22 Jun 2019

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc