Skip to content

Instantly share code, notes, and snippets.

@jgatjens
Created August 10, 2015 15:51
Show Gist options
  • Save jgatjens/565e1c773c9c3c2e24a5 to your computer and use it in GitHub Desktop.
Save jgatjens/565e1c773c9c3c2e24a5 to your computer and use it in GitHub Desktop.
Gulp - SVGs sprite generator - include content into html
// Combine svg files and inject it into index.html
gulp.task('svg', () => {
var svgs = gulp
.src('app/images/svg/*.svg')
.pipe($.svgmin())
.pipe($.svgstore({ inlineSvg: true }));
function fileContents (filePath, file) {
return file.contents.toString();
}
return gulp
.src('app/index.html')
.pipe($.inject(svgs, { transform: fileContents }))
.pipe(gulp.dest('app'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment