@exodus/svgr-rollup
TypeScript icon, indicating that this package has built-in type declarations

6.3.1-exodus-1 • Public • Published

@svgr/rollup

Build Status Version MIT License

Rollup plugin for SVGR.

npm install @svgr/rollup --save-dev

In your rollup.config.js:

{
  plugins: [svgr()]
}

In your code:

import Star from './star.svg'

const App = () => (
  <div>
    <Star />
  </div>
)

Passing options

{
  plugins: [svgr({ native: true })]
}

Using with url plugin

It is possible to use it with url.

In your rollup.config.js:

{
  plugins: [url(), svgr()]
}

In your code:

import starUrl, { ReactComponent as Star } from './star.svg'

const App = () => (
  <div>
    <img src={starUrl} alt="star" />
    <Star />
  </div>
)

The named export defaults to ReactComponent, but can be customized with the namedExport option.

Please note that by default, @svgr/rollup will try to export the React Component via default export if there is no other plugin handling svg files with default export. When there is already any other plugin using default export for svg files, @svgr/rollup will always export the React component via named export.

If you prefer named export in any case, you may set the exportType option to named.

Use your own Babel configuration

By default, @svgr/rollup applies a babel transformation with optimized configuration. In some case you may want to apply a custom one (if you are using Preact for an example). You can turn off Babel transformation by specifying babel: false in options.

{
  plugins: [svgr({ babel: false })]
}

License

MIT

Versions

Current Tags

Version History

Package Sidebar

Install

npm i @exodus/svgr-rollup

Weekly Downloads

4

Version

6.3.1-exodus-1

License

MIT

Unpacked Size

22.3 kB

Total Files

8

Last publish

Collaborators

  • tunguyennnnn
  • dimartiro
  • cdotta-exodus
  • awesomeniko
  • mbaraniak-exodus
  • maksim-iv-exodus
  • hasakura
  • milanvojnovic
  • olerass-exodus
  • kklash
  • shehryar6
  • rec
  • awilson-rs
  • ggabarrin-rs
  • r4vn
  • exorich
  • cryptosgr
  • mol0d
  • yevhenii_molodyk
  • yilmazbahadir
  • muratso
  • exoleo
  • 633kh4ck
  • ossel
  • davidfraga610
  • clarkexo
  • andrewrexo
  • james-gre
  • juraex
  • richayotte
  • ralph.ba
  • angelloz
  • joshuabot
  • jamiemaw
  • exodus-justin.za
  • javiexodus
  • rg911
  • alex.alexandrius
  • filipexodus
  • ryansquared-npm
  • andrescarreon
  • florianmathieu
  • janwe
  • fboucquez
  • skapala
  • umito
  • lanahizzle
  • iaacek
  • ps.mcnally
  • akinncar
  • matias.la
  • voltagebots
  • kwwood
  • sergii_bo
  • lekzd
  • alexandrbbm
  • danh.t.vo
  • ezenwankwogabriel
  • meniem
  • mzndako
  • kevva
  • feri42
  • jprichardson
  • farisissa
  • ryanzim
  • headfire
  • gutenye
  • mosesbot
  • roccomuso
  • dcastagnoli
  • sonaye
  • nareg_exodus
  • ves
  • tenaciousmv
  • asyakost
  • bulgakovk
  • chalker
  • andrejb
  • jaydp17
  • olistic
  • joepie91
  • merlz
  • vbonini
  • devopsrobot
  • jenish-sojitra
  • nachoalvarez
  • giovannirco
  • diegomura
  • lanre-mark
  • sunilagrawal
  • guillecura
  • mariosvlad
  • federico-po
  • pagan404