Socket
Socket
Sign inDemoInstall

babel-plugin-jsx-svg-icon-inject

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-jsx-svg-icon-inject

This plugin that translates this: ```jsx ```


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
7.86 kB
Created
Weekly downloads
 

Readme

Source

babel-plugin-jsx-svg-icon-inject

This plugin that translates this:

<Icon name="eye" />

into this:

var _iconMarkupEye = require("some-path/eye.svg");

<Icon markup={_iconMarkupEye} />;

It does not contain any implementation of the Icon component or a loader for the svg icons.

Usage

Install from the npm and then add this to .babelrc:

{
  "plugins": [
    ["jsx-svg-icon-inject", {
      "path": "some-path",
      "tagName": "Icon"
    }]
  ]
}

Options

path (required)

If the path is absolute, it will stay as is in require.

If the path is relative (e.g. ./some-path), it will be resolved using the current working directory, and the path in require will be relative wrt the transpiled script.

Else the path is treated as a "package name" and is left as is.

tagName (required)

Only the tags that have this name will be processed.

namePropName

Default: 'name'

The value of the prop with this name will be used for getting the icon path.

markupPropName

Default: 'markup'

The value of the prop with this name will be used for setting the icon markup.

License

Copyright (c) 2017 Rafał Ruciński. Licensed under the MIT license.

FAQs

Last updated on 09 Jan 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc