Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://github.com/twolfson/gulp.spritesmith
- // Example task with retina setup:
- // @1x and @2x should have exact proportions
- // otherwise spritesmith throws:
- // Error: Normal sprite has inconsistent size with retina sprite.
- // details and workaround: https://github.com/twolfson/gulp.spritesmith/issues/57
- const elixir = require('laravel-elixir');
- const Task = elixir.Task;
- const gulp = require('gulp');
- const spritesmith = require('gulp.spritesmith');
- const buffer = require('vinyl-buffer');
- const imagemin = require('gulp-imagemin');
- const del = require('del');
- const merge = require('merge-stream');
- elixir.extend('makeSprites', function() {
- new Task('makeSprites', function() {
- let spriteData = gulp.src('path_to_source/*.png')
- .pipe(spritesmith({
- retinaSrcFilter: ['path_to_source/*@2x.png'],
- imgName: 'sprite.png',
- retinaImgName: 'sprite@2x.png',
- cssName: 'sprite.less',
- imgPath: 'path_to_use_in_css/sprite.png'
- }));
- let imgStream = spriteData.img
- .pipe(buffer())
- .pipe(imagemin())
- .pipe('path_to_source_image_folder');
- let cssStream = spriteData.css
- .pipe('path_to_source_less_folder');
- return merge(imgStream, cssStream);
- });
- });
- elixir(mix => {
- // ...
- mix.makeSprites();
- //...
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement