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-divivudash@cometchat/uikit-resources@cometchat/uikit-shared@c2fo/components@bondsports/calendar@bondsports/consumer@bondsports/utils@blockless/ui-components@pectin/corejb-design-systemjump-vs-notificationkiban-design-systemreact-lite-playersp-storybook-ui-componentssp-player-reactuikit-resources-lernauikit-resources-lerna-cloneuikit-utils-lernauikit-resources-copyui-kit-pma1toasts-library-andrei@biotope/build@21torr/firefly@ace5040/demo2@codeunic/library-uixsola-shared-components-libwavelet-faucettsdx-with-svg@femate/img-preview@ecl/builder@gokul1630/react@lvxiaowu/cbay-ui@equinor/engineering-symbols@minox/customizer@minox/devtools@minox/themed@metacell/meta-diagram@komus/design@polymeshdev/ui@ocleva/bridgelink@slikmen/my-vd-components@senada/uikit@rockinblocks/rockinblocks@robbie-cook/react-componentsmy-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-library
2.0.0

6 years ago

1.0.1

8 years ago

1.0.0

8 years ago