|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | # @svgr/core
|
|---|
| 2 |
|
|---|
| 3 | [![Build Status][build-badge]][build]
|
|---|
| 4 | [![version][version-badge]][package]
|
|---|
| 5 | [![MIT License][license-badge]][license]
|
|---|
| 6 |
|
|---|
| 7 | Node API of SVGR.
|
|---|
| 8 |
|
|---|
| 9 | ```
|
|---|
| 10 | npm install @svgr/core
|
|---|
| 11 | ```
|
|---|
| 12 |
|
|---|
| 13 | ## Usage
|
|---|
| 14 |
|
|---|
| 15 | ```js
|
|---|
| 16 | import svgr from '@svgr/core'
|
|---|
| 17 |
|
|---|
| 18 | const svgCode = `
|
|---|
| 19 | <svg xmlns="http://www.w3.org/2000/svg"
|
|---|
| 20 | xmlns:xlink="http://www.w3.org/1999/xlink">
|
|---|
| 21 | <rect x="10" y="10" height="100" width="100"
|
|---|
| 22 | style="stroke:#ff0000; fill: #0000ff"/>
|
|---|
| 23 | </svg>
|
|---|
| 24 | `
|
|---|
| 25 |
|
|---|
| 26 | svgr(svgCode, { icon: true }, { componentName: 'MyComponent' }).then(
|
|---|
| 27 | (jsCode) => {
|
|---|
| 28 | console.log(jsCode)
|
|---|
| 29 | },
|
|---|
| 30 | )
|
|---|
| 31 | ```
|
|---|
| 32 |
|
|---|
| 33 | Use `svgr.sync(code, config, state)` if you would like to use sync version.
|
|---|
| 34 |
|
|---|
| 35 | ### Plugins
|
|---|
| 36 |
|
|---|
| 37 | By default `@svgr/core` doesn't include `svgo` and `prettier` plugins, if you want them, you have to install them and include them in config.
|
|---|
| 38 |
|
|---|
| 39 | ```js
|
|---|
| 40 | svgr(svgCode, {
|
|---|
| 41 | plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx', '@svgr/plugin-prettier'],
|
|---|
| 42 | }).then((jsCode) => {
|
|---|
| 43 | console.log(jsCode)
|
|---|
| 44 | })
|
|---|
| 45 | ```
|
|---|
| 46 |
|
|---|
| 47 | ## License
|
|---|
| 48 |
|
|---|
| 49 | MIT
|
|---|
| 50 |
|
|---|
| 51 | [build-badge]: https://img.shields.io/travis/smooth-code/svgr.svg?style=flat-square
|
|---|
| 52 | [build]: https://travis-ci.org/smooth-code/svgr
|
|---|
| 53 | [version-badge]: https://img.shields.io/npm/v/@svgr/core.svg?style=flat-square
|
|---|
| 54 | [package]: https://www.npmjs.com/package/@svgr/core
|
|---|
| 55 | [license-badge]: https://img.shields.io/npm/l/@svgr/core.svg?style=flat-square
|
|---|
| 56 | [license]: https://github.com/smooth-code/svgr/blob/master/LICENSE
|
|---|
| 57 |
|
|---|
| 58 | ```
|
|---|
| 59 |
|
|---|
| 60 | ```
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.