Giter Club home page Giter Club logo

gulp-sprite-glue's Introduction

gulp-sprite-glue

Build Status npm version

gulp-sprite-glue plugin for gulp

Required

This plugin requires

Usage

First, install gulp-sprite-glue as a development dependency:

npm install --save-dev gulp-sprite-glue

Then, add it to your gulpfile.js:

var glue = require("gulp-sprite-glue");

gulp.src("./src/*")
	.pipe(glue("/path/to/sprites",{
		// options
	}));
	//glue("dest path",options);

or

var glue = require("gulp-sprite-glue");

gulp.src("./src/*")
	.pipe(glue({
	    css: '/path/to/css_dest',
	    img: '/path/to/img_dest'
	}));
	//glue(options);
	//Both css and img options required.

API

gulp-sprite-glue(options)

options.crop

Type: Boolean Default value: false

Optimize our sprite by croping all the unnecessary transparent spaces that the original images could have.

options.caat

Type: Boolean Default value: false

Generate both a sprite image and a caat metadata file.

options.cachebuster

Type: Boolean Default value: false

Automatically add the hash of the PNG file to the CSS url

options.cachebusterFilename

Type: String Default value: null

Insted of using the hash of the PNG as a queryarg it uses it as part of the filename.

options.cachebusterFilenameOnlySprites

Type: Boolean Default value: false

Only apply filename cachebusting to the sprite image and not to both the CSS and the sprite image.

options.cocos2d

Type: Boolean Default value: false

Generate both a sprite image and a xml metadata file compatible with cocos2d.

options.css

Type: String Default value: null

Choose an individual folder for css you.

options.img

Type: String Default value: null

Choose an individual folder for image.

options.cssTemplate

Type: String Default value: null

You can use your own css template

options.force

Type: Boolean Default value: false

In order to avoid this behaviour you can use force and glue will always build the sprites.

options.followLinks

Type: Boolean Default value: false

Follow symbolic links.

options.html

Type: Boolean Default value: false

Generate a test html per sprite using all the available CSS classes. This option is only useful for testing purposes.

options.json

Type: Boolean Default value: false

Generate both a sprite image and a json metadata file.

options.jsonFormat

Type: String Default value: null

You can customize how the generated JSON will look. You can choose between array and hash.

options.less

Type: Boolean Default value: false

Glue can also create .less files

options.lessTemplate

Type: String Default value: null

You can use your own less template

options.margin

Type: Number Default value: null

If you want to spread the images around the sprite but you don’t want to count this space as image width/height.

options.namespace

Type: String Default value: null

your own namespace you can override the default one.

options.noImg

Type: Boolean Default value: false

Don’t create any sprite image.

options.noCss

Type: Boolean Default value: false

Don’t create any CSS file.

options.ordering

Type: String Default value: null

Before processing the images using the algorithm glue orders the images.

  • maxside
  • width
  • height
  • area
  • filename

options.padding

Type: Number Default value: null

If you want to add the same padding around all images.

options.png8

Type: Boolean Default value: false

By using the flag png8 the output image format will be png8 instead of png32.

options.project

Type: Boolean Default value: false

Generate several sprites for a project.

options.pseudoClassSeparator

Type: String Default value: null

using the filename of the source images you can customize the pseudo class related to the images.

options.quiet

Type: Boolean Default value: false

This flag will make glue suppress all console output.

options.recursive

Type: Boolean Default value: false

Read directories recursively and add all the images to the same sprite.

options.ratios

Type: String Default value: null

Automatically scale down your sprites to automatically fit them into low-dpi devices.

options.retina

Type: Boolean Default value: false

The option retina is only a shortcut for ratios=2,1.

options.source

Type: String Default value: null

Source directory.

options.output

Type: String Default value: null

Output directory.

options.scss

Type: Boolean Default value: false

Glue can also create .scss files.

options.scssTemplate

Type: String Default value: null

You can use your own scss template

options.separator

Type: String Default value: null

Separator for the CSS class names.

options.spriteNamespace

Type: String Default value: null

Sprite’s name as past of the CSS class namespace.

options.url

Type: String Default value: null

PNG file name the relative url between the CSS and the PNG file.

options.watch

Type: Boolean Default value: false

While you are developing a site it could be quite frustrating running Glue.

Test

npm test

License

MIT

Copyright (c) 2014 frontainer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

gulp-sprite-glue's People

Contributors

2no avatar mike183 avatar mrkipling avatar sable-virt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

gulp-sprite-glue's Issues

Destination folder with or without img/css options

When the user wants to specify specific IMG and CSS destination folder, the "dest" in the command must be empty. This is what happens if you try to launch the command with both:

Usage: glue [options] source_dir [<output> | --css=<dir> --img=<dir>]
glue: error: You must choose the output folder using either the output argument or both --img and --css.

So in the documentation it would be better to clarify it. Also, in the code, line 116:

if (!dest) {
  this.emit('error', new gutil.PluginError('gulp-sprite-glue', 'required dest path.'));
  callback();
}

the check should be different: you should throw an error only if the dest is null and one of the img/css options is null.

Let me know if you want to apply the changes yourself or prefer me to create a pull request.

gulp-sprite-glue working but not sprite images

Hello . Very got plugin and what is bad' that is work only once and then stop working. i got issue that sprite glue is running but not saving images and css.
it is happended on windows and also ubuntu.
here the task

    gulp.task('glue-sprite', function () {
    gulp.src('src/img')
        .pipe(glue({
            css: 'dest/css',
            img: 'dest/img'
   }));

in console i got this message

 gulp glue-sprite                                                                                                                                                       master [c053020] deleted modified untracked
[00:18:53] Using gulpfile /var/www/ANGULAR/learning-gulp/gulpfile.js
[00:18:53] Starting 'glue-sprite'...
[00:18:53] Finished 'glue-sprite' after 4.8 ms
[00:18:53] Execute: glue "/var/www/ANGULAR/learning-gulp/src/img" --css=dest/css --img=dest/img

and nothing happened. i cant understand what happened why he stop working?

thank you for help.

spriteNamespace and namespace should allow empty string as value

At the line
https://github.com/frontainer/gulp-sprite-glue/blob/master/index.js#L117
you are checking that the option is not false as negation of the value set; but on this case, is a user wants to add an empty string as value for the spriteNamespace and namespace options, the test results as true, and the script falls back to the predefined option. In this case, the option is not set, and the gulp library use the default values (which are not empty strings).
Simply put: to output this command:

glue [path_to_images] --scss --recursive --namespace=sprite --sprite-namespace= --img=build/dev/images/ --css=build/dev/sass

you have to set the option in this way:

{ namespace: ' ', spriteNamespace: ' ' }

that is, using spaces.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.