1.0.0-alpha.4 • Published 5 months ago
@hidoo/gulp-task-build-sprite-image v1.0.0-alpha.4
@hidoo/gulp-task-build-sprite-image
Task that build image sprite sheet for gulp.
Installation
$ npm install --save-dev gulp@next @hidoo/gulp-task-build-sprite-imageUsage
import { task } from 'gulp';
import buildSprite from '@hidoo/gulp-task-build-sprite-image';
task(
'sprite',
buildSprite({
src: '/path/to/sprite/*.png',
destImg: '/path/to/dest/image',
destCss: '/path/to/dest/css',
imgName: 'sprite.png',
cssName: 'sprite.styl',
imgPath: './image/sprite.png'
})
);Supported formats
- PNG
- JPEG
GIF (Partical support)
- Alpha GIF and Animated GIF are not support.
API
gifsicle
mozjpeg
optipng
buildSprite
return build image sprite sheet task
Parameters
optionsObject option (optional, default{})options.nameString task name (use as displayName) (optional, default'build:sprite')options.srcString source pathoptions.destImgString destination image pathoptions.destCssString destination css pathoptions.imgNameString destination image filenameoptions.cssNameString destination css filenameoptions.imgPathString destination image path in cssoptions.paddingNumber padding between image in sprite sheet. see: gulp.spritesmith (optional, default2)options.algorithmString algorithm for generate sprite sheet. see: gulp.spritesmith (optional, default'binary-tree')options.engineString engine for generate sprite sheet. see: gulp.spritesmith (optional, default'pixelsmith')options.cssPreprocessorString type of css preprocessor (one of [stylus|sass|sass:module]). (optional, default'stylus')options.cssTemplateString Handlebars template for css.options.cssPreprocessoris ignored if this value is specified. see: default template (optional, defaultpath.resolve(__dirname,'../template/stylus.hbs'))options.cssHandlebarsHelpersObject Handlebars helpers (optional, defaultrequire('@hidoo/handlebars-helpers'))options.evenizeBoolean apply evenize or not (optional, defaultfalse)options.compress(Boolean | Object) compress file whether or not (optional, defaultfalse)options.compress.imageminArray[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function) list of imagemin plugins
options.verboseBoolean out log or not (optional, defaultfalse)
Examples
import { task } from 'gulp';
import buildSprite, {
gifsicle,
mozjpeg,
optipng
} from '@hidoo/gulp-task-build-sprite-image';
task(
'sprite',
buildSprite({
name: 'sprite:main',
src: '/path/to/sprite/*.png',
destImg: '/path/to/dest/image',
destCss: '/path/to/dest/css',
imgName: 'sprite.png',
cssName: 'sprite.styl',
imgPath: './path/from/css/to/sprite/sprite.png',
padding: 10,
algorithm: 'top-down',
engine: 'pixelsmith',
cssPreprocessor: 'sass',
cssTemplate: '/path/to/template/sass.hbs',
cssHandlebarsHelpers: { hoge: (value) => value },
evenize: true,
compress: {
imagemin: [
gifsicle({ interlaced: true }),
mozjpeg({ quality: 90, progressive: true }),
optipng({ optimizationLevel: 5 })
]
},
verbose: true
})
);Returns Function[Stream](https://nodejs.org/api/stream.html)
Test
$ pnpm testLicense
MIT
1.0.0-alpha.4
5 months ago
1.0.0-alpha.3
6 months ago
1.0.0-alpha.2
7 months ago
1.0.0-alpha.1
2 years ago
1.0.0-alpha.0
2 years ago
0.19.0
4 years ago
0.18.0
5 years ago
0.17.0
5 years ago
0.16.0
5 years ago
0.15.0
6 years ago
0.14.1
6 years ago
0.14.0
6 years ago
0.13.0
6 years ago
0.12.0
6 years ago
0.11.0
6 years ago
0.10.0
6 years ago
0.9.0
6 years ago
0.8.4
7 years ago
0.8.3
7 years ago
0.8.2
7 years ago
0.8.1
7 years ago
0.8.0
7 years ago
0.7.0
7 years ago
0.6.2
7 years ago
0.6.1
7 years ago
0.6.0
7 years ago
0.5.0
7 years ago
0.4.0
7 years ago
0.3.0
7 years ago
0.2.1
7 years ago
0.2.0
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago