Skip to content

Commit

Permalink
Merge pull request gregberge#634 from gregberge/various-fixes
Browse files Browse the repository at this point in the history
various fixes
  • Loading branch information
gregberge authored Nov 29, 2021
2 parents 81369db + 73e78b8 commit 1cf431a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
7 changes: 5 additions & 2 deletions api/api/svgr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const { default: svgr } = require('@svgr/core')
const { transform } = require('@svgr/core')
const { default: jsx } = require('@svgr/plugin-jsx')
const { default: svgo } = require('@svgr/plugin-svgo')
const { default: prettier } = require('@svgr/plugin-prettier')
Expand All @@ -9,7 +9,10 @@ module.exports = (req, res) => {
res.status(204).send('')
return
}
svgr(req.body.code, { ...req.body.options, plugins: [svgo, jsx, prettier] })
transform(req.body.code, {
...req.body.options,
plugins: [svgo, jsx, prettier],
})
.then((output) => {
res.status(200).json({ output })
})
Expand Down
32 changes: 27 additions & 5 deletions website/pages/docs/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,27 @@ Disable runtime config (`.svgrrc`, `.svgo.yml`, `.prettierrc`).
| ------- | --------------------- | ----------------------- |
| `true` | `--no-runtime-config` | `runtimeConfig: <bool>` |

## File extension
## JSX runtime

Specify a custom extension for generated files.
Specify a JSX runtime to use.

| Default | CLI Override | API Override |
| ------- | ------------ | --------------- |
| `"js"` | `--ext` | `ext: <string>` |
- "classic": adds `import * as React from 'react'` on the top of file
- "automatic": do not add anything
- "classic-preact": adds `import { h } from 'preact'` on the top of file

| Default | CLI Override | API Override |
| --------- | --------------- | ----------------------- | ----------- | ------------------ |
| `classic` | `--jsx-runtime` | `jsxRuntime: <'classic' | 'automatic' | 'classic-preact'>` |

## JSX runtime import source

Specify a custom JSX runtime source to use. Allows to customize the import added at the top of generated file.

Example: `jsxRuntimeImport: { source: 'preact', specifiers: ['h'] }` for "classic-preact" equivalent.

| Default | CLI Override | API Override |
| ------- | ------------ | ------------------------------------------------------------ |
| `null` | - | `jsxRuntimeImport: { source: string, specifiers: string[] }` |

## Icon

Expand Down Expand Up @@ -211,3 +225,11 @@ Specify a custom filename case. Possible values: `pascal` for PascalCase, `kebab
| Default | CLI Override | API Override |
| -------- | ----------------- | ------------------------ |
| `pascal` | `--filename-case` | `filenameCase: <string>` |

## File extension

Specify a custom extension for generated files.

| Default | CLI Override | API Override |
| ------- | ------------ | --------------- |
| `"js"` | `--ext` | `ext: <string>` |

0 comments on commit 1cf431a

Please sign in to comment.