2.0.0 • Published 5 years ago

rollup-plugin-svg v2.0.0

Weekly downloads
20,518
License
MIT
Repository
github
Last release
5 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/utils@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-play@komus/designr-lite-playerskola-componentssiro-media-library@robbie-cook/react-components@rockinblocks/rockinblockssapper-ui-react-components@slikmen/my-vd-components@lvxiaowu/cbay-uireact-profile-componentreact-rollupreact-js-bottom-sheetreact-ir-banks-logo@metacell/meta-diagramreact-bootstrap-tworeact-connection-notificationreact-component-test-libraryreact-fule-uireact-block-mappss-form-jsselect-menu--p14sp-player-reactsp-storybook-ui-componentssportstalk-react-chatsoftlightweb@senada/uikit@trackmatic/yard-ui-commontf-checkout-react@truerenton/uilibtest-shared-ui-components-fox-xla-testthemebooktest-react-freshutest-mylib3@polymeshdev/uisalmon-ui-kitrncb-component-lib@pectin/coretest-design-system-buttonsvelte-ui-components@steedos-ui/builder-ag-gridreact-lite-playerepcs-disps-serviceepcs-permitnsr-servicedsgsdynamic-form-questionnairefrontend-tasksfwm-uiget-things-donedbi-componentsmadhank-k-kitmadhank-meta-kitmy-test-toasts-libmodsen-toasts-lib@ecl/builderdoggy-modsen-componentslogmar-uikutai-uxui-frameworkkyz-editorlaboratoria-uihns-lost-and-found@equinor/engineering-symbols@femate/img-previewdecal-componentsdesign-system-biginflectionpoints-uihorizon-color-pickerkiban-design-systemjump-vs-notificationjb-design-systempalitra-vue3-comments-componentoptimus-ui@21torr/firefly@vonage/video-expressuwdata-diviv.koriagin@ace5040/demo2auroruivudashuikit-resources-copyuikit-resources-lerna
2.0.0

5 years ago

1.0.1

7 years ago

1.0.0

7 years ago