Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow custom name for named export #493

Merged

Conversation

stefanprobst
Copy link
Contributor

Summary

This adds a namedExport config option to change the named export of the react component, when svgr is used in a loader chain together with something like file-loader. Still defaults to ReactComponent.

Example

// webpack.config.js
module.exports = {
  /* ... */
  module: {
    rules: [
      {
        test: /\.svg$/,
        use: [
          {
            loader: '@svgr/webpack',
            options: {
              namedExport: 'Svg', // defaults to 'ReactComponent'
            },
          },
          { loader: 'file-loader' },
        ],
      },
    ],
  },
}

will allow:

import { Svg as Logo } from 'assets/logo.svg'

Test plan

added tests + docs

@vercel
Copy link

vercel bot commented Sep 22, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/gregberge/svgr/dke6a67kx
✅ Preview: https://svgr-git-fork-stefanprobst-feat-allow-custom-named-export.gregberge.vercel.app

@gregberge gregberge merged commit 16a58d6 into gregberge:master Nov 14, 2020
@gregberge
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants