Skip to content

Instantly share code, notes, and snippets.

@fanweixiao
Forked from elrrrrrrr/gulpfile.js
Last active October 30, 2015 03:50
Show Gist options
  • Save fanweixiao/1c935a27af6257045dba to your computer and use it in GitHub Desktop.
Save fanweixiao/1c935a27af6257045dba to your computer and use it in GitHub Desktop.
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