gulp自动化管理精灵图

安装

npm install gulp –save-dev
npm install gulp.spritesmith –save-dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
var gulp = require('gulp');
var spritesmith = require('gulp.spritesmith');

gulp.task('autoSprite', function () {
gulp.src('./src/img/*.png').pipe(spritesmith({
imgName: 'sprite.png',
cssName: 'sprite.css',
padding: 20
})).pipe(gulp.dest('./dist/img/'));
});

gulp.task('default',['autoSprite'],function(){
console.log('运行成功')
})