Ejemplo n.º 1
0
function createSVGSprite(gulp, srcGlob, dest, svgSpriteConfig, jsxConfig) {
  var stream = gulp.src(srcGlob)
    .pipe(svgSprite(svgSpriteConfig))
    .pipe(gulp.dest(dest));

  // FIXXME: this is very specific at the moment. generalize!
  if (jsxConfig) {
    gulp.src(path.join(dest, 'symbol/svg/sprite.symbol.svg'))
      .pipe(html2jsx(jsxConfig.config))
      .pipe(replace('render: function() {', 'render() {'))
      .pipe(replace('{/*?xml version="1.0" encoding="utf-8"?*/}', ''))
      .pipe(replace(' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"', ''))
      .pipe(replace('<svg>', '<svg style={{display: "none"}}>'))
      .pipe(replace('var Icons = React.createClass({', 'export default class Icons extends React.Component {'))
      .pipe(replace('});', '}'))
      .pipe(rename('_icons.jsx'))
      .pipe(gulp.dest(jsxConfig.dest));
  }
  console.log('Wrote sprite files to %s', path.join(jsxConfig.dest));
}
Ejemplo n.º 2
0
 return function() {
   return gulp.src('./src/template/template.html')
     .pipe(html2jsx({/* if any opts */}))
     .pipe(gulp.dest('./src/template/out'));
 }