Skip to content

Commit

Permalink
Merge pull request gregberge#800 from aashrafh/remix-docs
Browse files Browse the repository at this point in the history
docs: document remix configuration
  • Loading branch information
gregberge authored Nov 25, 2022
2 parents d5efedd + c5ab231 commit 14d7024
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions website/pages/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SVGR provides a [powerful playground](https://react-svgr.com/playground/) for oc
If you want to automatise SVG transformation in your application, you should follow one of these guides:

- [Next.js](/docs/next/)
- [Remix](/docs/remix/)
- [webpack](/docs/webpack/)
- [Command Line](/docs/cli/)
- [Node.js](/docs/node-api/)
98 changes: 98 additions & 0 deletions website/pages/docs/remix.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
section: Usage
title: Remix
slug: /docs/remix/
order: 45
---

# Remix

Configure your [Remix](https://remix.run/) project to import SVG as React components in your application.

<carbon-ad />

## Install

```bash
npm install --save-dev @svgr/cli @svgr/plugin-svgo @svgr/plugin-jsx @svgr/plugin-prettier npm-watch npm-run-allnpm-watch npm-run-all
```

## Usage

Using SVGR into Remix is possible by configuring `package.json` scripts.

**package.json**

```js
{
//...
"scripts": {
//...

// task to convert icons to components
// you may change the input and output directories
"icons": "npx @svgr/cli --out-dir app/components/icons -- app/icons",

// watch task
"icons:watch": "npm-watch icons",

// compile once and start watching for changes
"dev:svg": "run-s icons icons:watch",

// remix dev
"dev:remix": "remix dev",

// run all dev: scripts including `dev:svg`
"dev": "run-p dev:*"
},
// npm-watch configuration
"watch": {
"icons": {
"patterns": [
"icons"
],
"extensions": "svg",
"quiet": false
}
},
//...
}
```

**svgr.config.js**

```js
module.exports = {
plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx', '@svgr/plugin-prettier'],
typescript: true,
}
```

**svgo.config.js**

```js
module.exports = {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
],
}
```

**Your code**

```js
import Star from '~/icons/star.svg'

const Example = () => (
<div>
<Star />
</div>
)
```

0 comments on commit 14d7024

Please sign in to comment.