File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- module . exports = function reactify ( filename , options ) {
1+ var through = require ( 'through' ) ,
2+ SVGO = require ( 'svgo' ) ,
3+ react = require ( 'react-tools' ) ;
24
3-
5+ var isSVG = function ( filename ) {
6+
7+ return ( / \. s v g $ / i) . test ( filename ) ;
8+ } ;
9+
10+ var svgo = new SVGO ( ) ;
11+
12+ module . exports = function ( filename ) {
13+
14+ var write = function ( buffer ) {
15+
16+ data += buffer ;
17+ } ;
18+
19+ var end = function ( ) {
20+
21+ svgo . optimize ( data , out ) ;
22+ } ;
23+
24+ var out = function ( svg ) {
25+
26+ var source = "var React = require('react');module.exports = React.createClass({render: function () { return (" + svg . data + "); }});" ,
27+ output = react . transform ( source , {
28+ es5 : true ,
29+ sourceMap : false ,
30+ sourceFilename : filename ,
31+ stripTypes : false ,
32+ harmony : false
33+ } ) ;
34+
35+ stream . queue ( output ) ;
36+ stream . queue ( null ) ;
37+ } ;
38+
39+ var data = '' ,
40+ stream = isSVG ( filename ) ? through ( write , end ) : through ( ) ;
41+
42+ return stream ;
443} ;
Original file line number Diff line number Diff line change 44 "homepage" : " https://github.com/coma/svg-reactify" ,
55 "repository" : " https://github.com/coma/svg-reactify" ,
66 "main" : " ./index.js" ,
7- "version" : " 0.0 .0" ,
7+ "version" : " 0.2 .0" ,
88 "license" : " MIT" ,
99 "private" : false ,
1010 "authors" : [
1616 " svg" ,
1717 " browserify-transform"
1818 ],
19- "dependencies" : {},
19+ "dependencies" : {
20+ "through" : " ^2.3" ,
21+ "react-tools" : " ^0.13" ,
22+ "svgo" : " ^0.5"
23+ },
2024 "devDependencies" : {},
2125 "scripts" : {},
2226 "engines" : {}
You can’t perform that action at this time.
0 commit comments