Original author @nightwolfz (https://github.com/nightwolfz). However, the repo is not available on GitHub (anymore?).
Just putting it here for my own use.
Finds all svg files require'd in as a React Component and inlines them.
It should work with both the server-side rendering and on the browser.
module: {
loaders: [{
test: /\.svg$/,
exclude: /(node_modules)/,
loaders: ['react-svg-inline-loader']
}]
}
var React = require('react')
var SvgPicture = require('./picture.svg')
class TestComponent extends React.Component {
constructor(props, context) {
super(props, context)
}
render() {
return <SvgPicture className="big red icon"/>
}
}
node (version 4 or higher)
npm install @jonathan.alzetta/react-svg-inline-loader --save
mocha
Nothing external