2.1.13 • Published 6 years ago

gulp-sprite-by-ext v2.1.13

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

gulp-sprite-by-ext

npm version

Sprite generator by extension file by gulp.

Installation

Install with npm:

npm install --save-dev gulp-sprite-by-ext

Usage

Sprite-By-Ext is a gulp task for generate sprite image and style by type of file image. below is a simple example for use:

const gulp        = require('gulp');
const spriteByExt = require('gulp-sprite-by-ext');

gulp.task('sprite-by-ext', function () {
    return gulp.src(['./images/**/*'])
    .pipe(spriteByExt())
    .pipe(gulp.dest('./dist'));
});

Options

Sprite-By-Ext can accept some options for use:

const gulp        = require('gulp');
const spriteByExt = require('gulp-sprite-by-ext');

gulp.task('default', function () {
    return gulp.src(['./images/**/*.{png,jpg,svg}'])
    .pipe(spriteByExt({
        css: {
            imagePath: '../images/',    // Path to write on CSS for image address
        },
        slug: (id, ext) => ext + '-' + id, // Pattern of class name and symbols id
        filename: 'sprite',
        filename2x: 'sprite@2x',
    }))
    .pipe(gulp.dest('./build'));
});

Plugin options are:

PropertyNecessaryTypePlugin default value
css.imagePathnoString../images/
slugnofunction(id, ext) => ext + '-' + id
filenamenoStringsprite
filename2xnoStringsprite@2x

More detailed explanation is below.

css.imagePath

Type: String Default value: ../images/

Defines which folder will have the image in css.

slug

Type: function Returns: String Default value: (id, ext) => ext + '-' + id

Defines class name pattern in css.

filename

Type: String Default value: sprite

Defines name pattern of sprite output file.

filename

Type: String Default value: sprite@2x

Defines name pattern of sprite retina output file.

2.1.13

6 years ago

2.1.12

6 years ago

2.1.11

7 years ago

2.1.10

7 years ago

2.1.9

7 years ago

2.1.8

7 years ago

2.1.7

7 years ago

2.1.6

7 years ago

2.1.5

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago