source: frontend/node_modules/@svgr/plugin-jsx/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.4 KB
Line 
1# @svgr/plugin-jsx
2
3[![Build Status](https://img.shields.io/travis/smooth-code/svgr.svg)](https://travis-ci.org/smooth-code/svgr)
4[![Version](https://img.shields.io/npm/v/@svgr/plugin-jsx.svg)](https://www.npmjs.com/package/@svgr/plugin-jsx)
5[![MIT License](https://img.shields.io/npm/l/@svgr/plugin-jsx.svg)](https://github.com/smooth-code/svgr/blob/master/LICENSE)
6
7Transforms SVG into JSX.
8
9## Install
10
11```
12npm install --save-dev @svgr/plugin-jsx
13```
14
15## Usage
16
17**.svgrrc**
18
19```json
20{
21 "plugins": ["@svgr/plugin-jsx"]
22}
23```
24
25## How does it work?
26
27`@svgr/plugin-jsx` consists in three phases:
28
29- Parsing the SVG code using [svg-parser](https://github.com/Rich-Harris/svg-parser)
30- Converting the [HAST](https://github.com/syntax-tree/hast) into a [Babel AST](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md)
31- Applying [`@svgr/babel-preset`](../babel-preset/README.md) transformations
32
33## Applying custom transformations
34
35You can extend the Babel config applied in this plugin using `jsx.babelConfig` config path:
36
37```js
38// .svgrrc.js
39
40module.exports = {
41 jsx: {
42 babelConfig: {
43 plugins: [
44 // For an example, this plugin will remove "id" attribute from "svg" tag
45 [
46 '@svgr/babel-plugin-remove-jsx-attribute',
47 {
48 elements: ['svg'],
49 attributes: ['id'],
50 },
51 ],
52 ],
53 },
54 },
55}
56```
57
58Several Babel plugins are available:
59
60- [`@svgr/babel-plugin-add-jsx-attribute`](../babel-plugin-add-jsx-attribute/README.md)
61- [`@svgr/babel-plugin-remove-jsx-attribute`](../babel-plugin-remove-jsx-attribute/README.md)
62- [`@svgr/babel-plugin-remove-jsx-empty-expression`](../babel-plugin-remove-jsx-empty-expression/README.md)
63- [`@svgr/babel-plugin-replace-jsx-attribute-value`](../babel-plugin-replace-jsx-attribute-value/README.md)
64- [`@svgr/babel-plugin-svg-dynamic-title`](../babel-plugin-svg-dynamic-title/README.md)
65- [`@svgr/babel-plugin-svg-em-dimensions`](../babel-plugin-svg-em-dimensions/README.md)
66- [`@svgr/babel-plugin-transform-react-native-svg`](../babel-plugin-transform-react-native-svg/README.md)
67- [`@svgr/babel-plugin-transform-svg-component`](../babel-plugin-transform-svg-component/README.md)
68
69If you want to create your own, reading [Babel Handbook](https://github.com/jamiebuilds/babel-handbook/blob/master/translations/en/plugin-handbook.md) is a good start!
70
71## License
72
73MIT
Note: See TracBrowser for help on using the repository browser.