Coder Social home page Coder Social logo

Comments (6)

kazijawad avatar kazijawad commented on August 20, 2024 3

@RIP21 Ah I see — yes this is currently possible with the SVGR API. It can be passed into the plugin options like this:

svgrPlugin({ exportType: 'named' })

It looks like the hosted SVGR documentation doesn't include all the possible options 😕
I tested it myself and was able to get import { ReactComponent } working. The named export can also be changed with the namedExport field. It might be useful to reference the SVGR source code.

from esbuild-plugin-svgr.

kazijawad avatar kazijawad commented on August 20, 2024

Hi, could you provide a code reference I could take a look at?

from esbuild-plugin-svgr.

hannadrehman avatar hannadrehman commented on August 20, 2024

@kazijawad i am trying to use it like its implemented in create react app . its mentioned here in their docs

import { ReactComponent as Logo } from './logo.svg';

function App() {
  return (
    <div>
      {/* Logo is an actual React component */}
      <Logo />
    </div>
  );
}

from esbuild-plugin-svgr.

kazijawad avatar kazijawad commented on August 20, 2024

Have you tried import Icon from './icon.svg';? If there is a repository I can look at that would be helpful.

from esbuild-plugin-svgr.

kazijawad avatar kazijawad commented on August 20, 2024

Closing this issue because of inactivity.

from esbuild-plugin-svgr.

RIP21 avatar RIP21 commented on August 20, 2024

@kazijawad default export works indeed. But most of the SVGR exports I saw generated by Webpack integration and Rollup integration generates a named export of ReactComponent
So import aDefault from './smth.svg' will give you a URL to a file to access or a base64 URL.
But import { ReactComponent } from './smth.svg' gives what your plugin gives now. So people that are looking for svgr plugin for esbuild look exactly for that UX and not the one you provide I think, maybe not by default, but at least some hint in the README :)
I want the same :)

from esbuild-plugin-svgr.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.