Nanoseconds Produce Minutes
    Have ideas to improve npm?Join in the discussion! »

    @svgr/rollup
    DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/svgr__rollup package

    5.5.0 • 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.

    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

    Install

    npm i @svgr/rollup

    DownloadsWeekly Downloads

    73,040

    Version

    5.5.0

    License

    MIT

    Unpacked Size

    13.3 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar