babel-plugin-transform-svg-import-to-string
v0.0.1
Published
Turn svg imports into strings
Downloads
3,186
Maintainers
Readme
babel-plugin-transform-svg-import-to-string
This is entirely based on yeiniel's (babel-plugin-transform-html-import-to-string)[https://github.com/yeiniel/babel-plugin-transform-html-import-to-string]. Turns svg imports into strings.
Example
Given the following example.svg.
<svg height="100" width="100">
<circle cx="50" cy="50" r="40" />
</svg>
in
import svg from './example.svg';
out
var svg = '<svg height="100" width="100"><circle cx="50" cy="50" r="40" /></svg>';
Installation
$ npm install babel-plugin-transform-svg-import-to-string
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["transform-html-import-to-string"]
}
Via CLI
$ babel --plugins transform-html-import-to-string script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["transform-svg-import-to-string"]
});