Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ruanyl/esbuild-plugin-react-svgr
esbuild plugin for react svgr
https://github.com/ruanyl/esbuild-plugin-react-svgr
esbuild react svgr
Last synced: 18 days ago
JSON representation
esbuild plugin for react svgr
- Host: GitHub
- URL: https://github.com/ruanyl/esbuild-plugin-react-svgr
- Owner: ruanyl
- License: mit
- Created: 2022-08-30T21:39:14.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-31T19:23:06.000Z (over 2 years ago)
- Last Synced: 2024-12-05T18:08:11.335Z (about 1 month ago)
- Topics: esbuild, react, svgr
- Language: TypeScript
- Homepage:
- Size: 281 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# esbuild-plugin-svgr
### Install
```
pnpm add esbuild-plugin-react-svgr -D
```### Usage
```typescript
import { build } from 'esbuild'build({
entryPoints: ['./logo.svg'],
plugins: [svgrPlugin()],
outdir: 'dist',
})
// Output ==============>
import * as React from "react";
const SvgLogo = (props) => /* @__PURE__ */ React.createElement("svg", {...});
export default SvgLogo;
```Build with svgr options
```typescript
import { build } from 'esbuild'build({
entryPoints: ['./logo.svg'],
plugins: [svgrPlugin({exportType: 'named'})],
outdir: 'dist',
})// Output ==============>
import * as React from "react";
const SvgLogo = (props) => /* @__PURE__ */ React.createElement("svg", {...});
export { SvgLogo as ReactComponent };
```Enable url export:
```typescript
// index.ts
import url, { ReactComponent } from './logo.svg'
``````typescript
import { build } from 'esbuild'build({
entryPoints: ['./index.ts'],
plugins: [svgrPlugin({}, {exportUrl: true})],
outdir: 'dist',
bundle: true,
loader: {
'.svg': 'file',
},
})// Output ==============>
// logo.svg
var logo_default = "./logo-4YCDN2WN.svg";// svgr:/Users/yulongruan/project/esbuild-plugin-svgr/src/__test__/fixtures/logo.svg
var React = __toESM(__require("react"));
var SvgLogo = (props) => /* @__PURE__ */ React.createElement("svg", {...});var logo_default2 = logo_default;
```