9/29/2017 - 3:42 PM

gulp.spritesmith demo

gulp.spritesmith demo

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="stylesheet" href="dist/sprite/sprite-test.css">
<body style="background: lightgreen">
  <div class="icon-guideH3"></div>
  <div class="icon-man"></div>
  <div class="icon-moreIcon"></div>
  <div class="icon-logowxb"></div>
  <div class="icon-logo"></div>
  <div class="icon-lexus"></div>
var gulp = require('gulp');
var buffer = require('vinyl-buffer');
var csso = require('gulp-csso');
var imagemin = require('gulp-imagemin');
var merge = require('merge-stream');

var spritesmith = require('gulp.spritesmith');

gulp.task('sprite-test', function () {
  // Generate our spritesheet
  var spriteData = gulp.src('image/test/*.png').pipe(spritesmith({
    imgName: 'sprite-test.png',
    cssName: 'sprite-test.css'

  // Pipe image stream through image optimizer and onto disk
  var imgStream = spriteData.img
    // DEV: We must buffer our stream into a Buffer for `imagemin`

  // Pipe CSS stream through CSS optimizer and onto disk
  var cssStream = spriteData.css

  // Return a merged stream to handle both `end` events
  return merge(imgStream, cssStream);

gulp.task('default', ['sprite-test']);