zoukankan      html  css  js  c++  java
  • gulp.spriteSmith使用

    var gulp = require('gulp');
    var spritesmith = require('gulp.spritesmith');
    
    gulp.task('sprite', function () {
      var spriteData = gulp.src('images/*.png').pipe(spritesmith({
        imgName: 'sprite.png',
        cssName: 'sprite.css'
      }));
      return spriteData.pipe(gulp.dest('path/to/output/'));
    });
    
    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', function () {
      // Generate our spritesheet
      var spriteData = gulp.src('images/*.png').pipe(spritesmith({
        imgName: 'sprite.png',
        cssName: 'sprite.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(buffer())
        .pipe(imagemin())
        .pipe(gulp.dest('path/to/image/folder/'));
    
      // Pipe CSS stream through CSS optimizer and onto disk
      var cssStream = spriteData.css
        .pipe(csso())
        .pipe(gulp.dest('path/to/css/folder/'));
    
      // Return a merged stream to handle both `end` events
      return merge(imgStream, cssStream);
    });
    

      

      

  • 相关阅读:
    html+css学习
    mac安装软件系列
    Versions 出现 SVN Working Copy xxx locked
    linux安装gcc-c++
    linux常用命令
    linux挂载磁盘
    对jquery新增加的class绑定事件
    linux下安装php的mcrypt拓展
    Linux关闭selinux
    linux安装包资源库
  • 原文地址:https://www.cnblogs.com/jymz/p/5993879.html
Copyright © 2011-2022 走看看