# babel-plugin-transform-jsx-url

> Convert URL to require or import sytanx in JSX.

Latest version **1.0.2** (published 2019-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-jsx-url
pnpm add babel-plugin-transform-jsx-url
yarn add babel-plugin-transform-jsx-url
bun add babel-plugin-transform-jsx-url
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-06-19 |
| First published | 2019-01-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | xyyjk |
| Maintainers | xyyjk |
| Keywords | babel-plugin, require, react, link, img, src, url, jsx |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-jsx-url
- Repository: https://github.com/xyyjk/babel-plugin-transform-jsx-url
- Homepage: https://github.com/xyyjk/babel-plugin-transform-jsx-url#readme
- Issues: https://github.com/xyyjk/babel-plugin-transform-jsx-url/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-jsx-url

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-06-19
- 1.0.1 — 2019-01-23
- 1.0.0 — 2019-01-04

## README

# babel-plugin-transform-jsx-url &middot; [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/xyyjk/babel-plugin-transform-jsx-url) [![npm version](https://img.shields.io/npm/v/babel-plugin-transform-jsx-url.svg)](https://www.npmjs.com/package/babel-plugin-transform-jsx-url)
Convert URL to require or import sytanx in JSX.

## Example

### In
``` html
<img src="/static/image.jpg" />
<link rel="stylesheet" href="/static/style.css" />
```

### Out
``` html
<img src={require("/static/image.jpg")} />
<link rel="stylesheet" href={require("/static/style.css")} />
```

## Installation
``` bash
npm install --save-dev babel-plugin-transform-jsx-url
```

## Usage
Without options:

``` js
{
  "plugins": ["transform-jsx-url"],
}
```

With options:

``` js
{
  "plugins": [
    ["transform-jsx-url", {
      "root": "/src",
      "attrs": ["img:src", "img:data-src", "link:href"],
    }],
  ],
}
```

### Options

#### root
`string`, defaults to `""`.

If a root query parameter is set, however, it will be prepended to the url and then translated.

#### Example
`"root": "/src"`

##### In
``` html
<img data-src="/static/image.jpg" />
```

##### Out
``` html
<img data-src={require("/src/static/image.jpg")} />
```

#### attrs
`Array`, defaults to `["img:src", "link:href"]` .

You can specify which tag-attribute combination should be processed by this loader. Pass an array or a space-separated list of <tag>:<attribute> combinations.

#### Example
`"attrs": ["img:data-src", "custom:src"]`

##### In
``` html
<img data-src="/static/image.jpg" />
<custom src="/static/image.jpg" />
```

##### Out
``` html
<img data-src={require("/static/image.jpg")} />
<custom src={require("/static/image.jpg")} />
```

---
_Source: https://npm.io/package/babel-plugin-transform-jsx-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
