2.0.0 • Published 6 years ago

rollup-plugin-svg v2.0.0

Weekly downloads
20,518
License
MIT
Repository
github
Last release
6 years ago

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

@bondsports/checkout_flownubex-shared-fronttamm-pkg-uigoodyui@bkinnamon/blademylib2-test-imgpackaged-ui@workrails/wr-catalog-basecommon-check-widgetbondsports-utils-test@vonage/multipartydecal-components-prova2@equinor/sparql-graphcomponents-seguros@thequack/sharedfule-uimui-react-chat@everything-registry/sub-chunk-2681smart-playsvelte-ui-componentstest-design-system-buttontest-mlm-npmtest-mylib3sportstalk-react-chattest-react-freshutest-shared-ui-components-fox-xla-testtf-checkout-reactthemebookviz-react-boilerplatev.koriaginuwdata-divivudashjb-design-systemjump-vs-notificationkiban-design-systeminflectionpoints-uihorizon-color-pickerhns-lost-and-foundmadhank-k-kitmadhank-meta-kitlogmar-uikutai-uxui-frameworklaboratoria-uikyz-editorkyz-toast@webtides/tasks@vergelijkdirect/my-vd-components@truerenton/uilib@trackmatic/yard-ui-common@upword_ai/uikit@vutien/interfacesdk@vonage/video-expressalvocom-stylesaurorui@ecl/builderreact-lite-playersp-storybook-ui-componentssp-player-reactuikit-resources-lernauikit-resources-lerna-cloneuikit-utils-lernauikit-resources-copyui-kit-pma1toasts-library-andrei@ace5040/demo2xsola-shared-components-libwavelet-faucettsdx-with-svg@gokul1630/reactmy-test-toasts-libmodsen-toasts-liboptimus-uioctopus-media-librarypayzli-uipalitra-vue3-comments-componentselect-menu--p14rncb-component-libreact-component-test-libraryreact-block-mapreact-connection-notificationreact-bootstrap-twosapper-ui-react-componentsreact-fule-uisalmon-ui-kitreact-js-bottom-sheetreact-ir-banks-logor-lite-playerpss-form-jsreact-profile-componentreact-rollupshared-raj-packagesoftlightwebskola-componentssiro-media-librarycomsa-componentscomponent-top-bar-testchriszig-zignaly-uicrayon-ui-kit-rajamanimarancrayon-ui-kitcrayon-ui-kit-dineshkumar
2.0.0

6 years ago

1.0.1

8 years ago

1.0.0

8 years ago