Skip to content

feat: allow custom name for named export#493

Merged
gregberge merged 1 commit into
gregberge:masterfrom
stefanprobst:feat/allow-custom-named-export
Nov 14, 2020
Merged

feat: allow custom name for named export#493
gregberge merged 1 commit into
gregberge:masterfrom
stefanprobst:feat/allow-custom-named-export

Conversation

@stefanprobst

Copy link
Copy Markdown
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

vercel Bot commented Sep 22, 2020

Copy link
Copy Markdown

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
Copy Markdown
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