Skip to content

Commit

Permalink
Better readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Gensler committed Sep 19, 2016
1 parent 3bb94bc commit c8f9e46
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion README.md
@@ -1,5 +1,60 @@
# babel-plugin-inline-react-svg

Inlines requires to SVG files so that they can be used seamlessly in your components.
Transforms imports to SVG files into React Components, and optimizes the SVGs with [SVGO](https://github.com/svg/svgo/).

For example, the following code...

```jsx
import React from 'react';
import CloseSVG from './close.svg';

export default const MyComponent = () => <CloseSvg />;
```

will be transformed into...

```jsx
import React from 'react';
const CloseSVG = () => <svg>{* ... *}</svg>;

export default const MyComponent = () => <CloseSvg />;
```

## Installation

```
npm install --save-dev babel-plugin-inline-react-svg
```

## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
"plugins": [
"inline-react-svg"
]
}
```

### Via CLI

```sh
$ babel --plugins inline-react-svg script.js
```

### Via Node API


```javascript
require('babel-core').transform('code', {
plugins: ['inline-react-svg']
}) // => { code, map, ast };
```

---

Inspired by and code foundation provided by [react-svg-loader](https://github.com/boopathi/react-svg-loader).

0 comments on commit c8f9e46

Please sign in to comment.