githubEdit

@svgr/webpack

Build Statusarrow-up-right Versionarrow-up-right MIT Licensearrow-up-right

Webpack loader for SVGR.

npm install @svgr/webpack

Usage

In your webpack.config.js:

{
  test: /\.svg$/,
  use: ['@svgr/webpack'],
}

In your code:

import Star from './star.svg'

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

Passing options

Using with url-loader or file-loader

It is possible to use it with url-loaderarrow-up-right or file-loaderarrow-up-right.

In your webpack.config.js:

In your code:

Use your own Babel configuration

By default, @svgr/webpack includes a babel-loader with an optimized configurationarrow-up-right. 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.

Handle SVG in CSS, Sass or Less

It is possible to detect the module that requires your SVG using Rule.issuerarrow-up-right in Webpack. Using it you can specify two different configurations for JavaScript and the rest of your files.

License

MIT

Last updated