Skip to content

Instantly share code, notes, and snippets.

@elrrrrrrr
Created September 25, 2014 13:23
Show Gist options
  • Save elrrrrrrr/26d392093f20acd83c69 to your computer and use it in GitHub Desktop.
Save elrrrrrrr/26d392093f20acd83c69 to your computer and use it in GitHub Desktop.
css sprites
var gulp = require('gulp');
var gulpif = require('gulp-if');
var sprite = require('css-sprite').stream;
var base = require('gulp-base64');
// generate sprite.png and _sprite.scss
gulp.task('sprites', function () {
return gulp.src('img/*.png')
.pipe(sprite({
name: 'tx.png',
style: '_sprite.styl',
cssPath: './img',
processor: 'stylus'
}))
.pipe(gulpif('*.png', gulp.dest('img'), gulp.dest('stylus')))
});
// generate scss with base64 encoded images
gulp.task('icon', function () {
return gulp.src('img/*.png')
.pipe(sprite({
base64: true,
style: '_base64.styl',
processor: 'stylus'
}))
.pipe(gulp.dest('stylus'));
});
gulp.task('base64', function () {
return gulp.src('css/*.css')
.pipe(base())
.pipe(gulp.dest('img/'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment