Comments (6)
@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.
Hi, could you provide a code reference I could take a look at?
from esbuild-plugin-svgr.
@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.
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.
Closing this issue because of inactivity.
from esbuild-plugin-svgr.
@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)
- ReactComponent as svg HOT 9
- Prevents the usage of `.svg` files from stylesheets via `url()` HOT 5
- SVG paths are not resolved
- [ERROR] Expected identifier but found "?" HOT 5
- Cannot be marked as external
- namedExport not working HOT 3
- Not working when bundle:false HOT 6
- pass filePath to svgr HOT 1
- Support Custom Filter HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esbuild-plugin-svgr.