svg-jsx-loader
WebPack loader that converts SVG files into React Components
Last updated 7 years ago by jannanista .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install svg-jsx-loader 
SYNC missed versions from official npm registry.

svg-jsx-loader

Webpack loader that allows you to load your SVG files as React components.

Build Status

Installation

npm install svg-jsx-loader

Usage

This loader outputs a React component. To use it for all of your .svg files you need to include it in your webpack module.loaders configuration as follows.

loaders: [
	{ test: /\.svg$/, loaders: ['babel?presets[]=react', 'svg-jsx'] }
]

To use it for individual files:

var MyComponent = require('babel?presets[]=react!svg-jsx!../svg/my_component.svg');

In both cases babel with react preset is required to transpile resulting JSX.

Options

Besides options that are passed to underlying svg-to-jsx module svg-jsx-loader supports a few options itself:

es6 {Boolean} Use ES6 compatible JavaScript syntax for component class. Defaults to false.

memo {Boolean} Only available when es6 option is set to true Use React.memo instead of React.PureComponent. Defaults to false.

displayName {String} displayName of generated class. Defaults to null.

Acknowledgements

This module was inspired by react-svg-loader.

Current Tags

  • 1.0.1                                ...           latest (7 years ago)

20 Versions

  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
  • 0.0.18                                ...           8 years ago
  • 0.0.17                                ...           9 years ago
  • 0.0.16                                ...           10 years ago
  • 0.0.15                                ...           10 years ago
  • 0.0.14                                ...           10 years ago
  • 0.0.13                                ...           10 years ago
  • 0.0.12                                ...           10 years ago
  • 0.0.11                                ...           10 years ago
  • 0.0.10                                ...           10 years ago
  • 0.0.9                                ...           11 years ago
  • 0.0.8                                ...           11 years ago
  • 0.0.7                                ...           11 years ago
  • 0.0.6                                ...           11 years ago
  • 0.0.5                                ...           11 years ago
  • 0.0.4                                ...           11 years ago
  • 0.0.3                                ...           11 years ago
  • 0.0.2                                ...           11 years ago
  • 0.0.1                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 10
Dependencies (3)
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |