GithubHelp home page GithubHelp logo

selaux / node-sprite-generator Goto Github PK

View Code? Open in Web Editor NEW
192.0 11.0 39.0 1.04 MB

Generates image sprites and their spritesheets (css, stylus, sass or less) from sets of images. Supports retina sprites. Provides express middleware and grunt task.

License: MIT License

JavaScript 93.94% Smarty 6.06%

node-sprite-generator's Introduction

node-sprite-generator

This project is no longer actively maintained

NPM Version Build Status Coverage Status Dependencies

Generates image sprites and their spritesheets (css, stylus, sass, scss or less) from sets of images. Supports retina sprites. Provides express middleware and grunt task.

Installation

npm install node-sprite-generator

Note: node-sprite-generator cen either use native libraries or pure javascript to build sprites which requires no native dependencies. To use the pure javascript compositor use 'jimp' as the compositor module.

  • Cairo needs to be installed when using the 'canvas' compositor because node-canvas depends on it. For more information how to do this on your system go to the node-canvas page. If you have issues installing node-canvas on OSX, please read Issue 23.
  • ImageMagick/GraphicsMagick needs to be installed when using the 'gm' compositor

Usage

Standalone

var nsg = require('node-sprite-generator');

nsg({
    src: [
        'images/sprite/*.png'
    ],
    spritePath: 'images/sprite.png',
    stylesheetPath: 'stylus/sprite.styl'
}, function (err) {
    console.log('Sprite generated!');
});

This will generate a sprite.png file and the corresponding stylus stylesheet, with can then be included from your stylus files.

With express.js

node-sprite-generator provides a middleware to use with express.js.

var nsg = require('node-sprite-generator'),
    express = require('express'),
    app = express();

app.use(nsg.middleware({
    src: [
        'images/sprite/*.png'
    ],
    spritePath: 'images/sprite.png',
    stylesheetPath: 'stylus/sprite.styl'
}));

Make sure that the node-sprite-generator middleware is used before any css preprocessors that use the generated stylesheet.

With grunt

node-sprite-generator also provides a grunt plugin. It takes the same options as the other two methods.

module.exports = function (grunt)  {

    grunt.initConfig({

        spriteGenerator: {
            sprite: {
                src: [
                    'images/sprite/*.png'
                ],
                spritePath: 'images/sprite.png',
                stylesheetPath: 'stylus/sprite.styl'
            }
        }

    });

    grunt.loadNpmTasks('node-sprite-generator');
};

Options

node-sprite-generator tries to be very modular, so you can use the options we provide or write your own functions/modules to further customize your sprites.

options.src

Type: String Default value: []
Specifies the images that will be combined to the sprite. node-sprite-generator uses glob pattern matching, so paths with wildcards are valid as well.

options.spritePath

Type: String Default value: ''
The path your image sprite will be written to. ATM we only support the PNG format for the image sprite.

options.stylesheetPath

Type: String Default value: ''
The path your stylesheet will be written to.

options.stylesheet

Type: String|Function Default value: 'stylus'
Specifies the sylesheet generator (and therefore the stylesheet format) that is used either by using one of the built-in formats or specifying a path to a custom template. It is also possible to specify a function that writes a custom stylesheet (see more at extending node-sprite-generator).

Built-in formats:

options.stylesheetOptions

Type: Object Default value: '{}'
Options that will be passed on to the stylesheet generator. The built-in stylesheet generators support the following options:
prefix (Type: String Default: ''): A prefix that will be prepended to all classes/functions that are generated
nameMapping (Type: Function Default: Filename): A function that specifies how filenames are mapped to class names in the stylesheet
spritePath (Type: String Default: Relative Path): Defines which URL is used as the image path for the image sprite.
pixelRatio (Type: Integer Default: 1): Specifies the pixelRatio for retina sprites.

options.layout

Type: String|Function Default value: 'vertical'
Specifies the layout that is used to generate the sprite by using one of the built-in layouts or using a function that generates a custom layout (see more at extending node-sprite-generator).

Built-in layouts:

  • 'packed': Bin-packing Layout
  • 'vertical': Vertically aligned layout
  • 'horizontal': Horizontally aligned layout
  • 'diagonal': Diagonally aligned layout

options.layoutOptions

Type: Object Default value: {}
Options that will be passed on to the layout generation. The built-in layouters support the following options.
padding (Type: Integer Default: 0): Specifies the padding between the images in the layout.
scaling (Type: Number Default: 1): Specifies the factor that the images are scaled with in the layout. This allows generating multiple, scaled versions of the same sprites using a single image set.

options.compositor

Type: String|Function Default value: 'canvas'
The compositor is used to read and render the images. Your can use one of the built-in options or specify your own module that implements this functionality. Have a look at extending node-sprite-generator to see how it's done.

Built-in compositors:

options.compositorOptions

Type: Object Default value: {}
Options that will be passed on to the compositor. The built-in compositor supports the following options:
compressionLevel (Type: Integer Default: 6): Specifies the compression level for the generated png file (compression levels range from 0-9).
filter (Type: String Default: all): Specifies the filter used for the generated png file. Possible values: all, none, sub, up, average, paeth.

A more advanced example

var nsg = require('node-sprite-generator');

nsg({
    src: [
        'public/images/sprite/*.png'
    ],
    spritePath: 'public/images/all-icons.png',
    stylesheetPath: 'public/stylesheets/all-icons.css',
    layout: 'diagonal',
    layoutOptions: {
        padding: 30
    },
    stylesheet: 'app/assets/sprites/template.tpl',
    stylesheetOptions: {
        prefix: 'all-icons',
        spritePath: 'http://static.your-server.org/images/all-icons.png',
        pixelRatio: 2
    }
});

This will generate a diagonally layouted retina-enabled sprite that can be accessed using classes like all-icons-home. The sprite will then be loaded from your static asset server.

Extending node-sprite-generator

The internal pipeline for node-sprite-generator is

  • compositor.readImages(files, callback) -> callback(error, images)
  • layout(images, options, callback) -> callback(error, layout)
  • compositor.render(layout, spritePath, options, callback) -> callback(error)
  • stylesheet(layout, stylesheetPath, spritePath, options, callback) -> callback(error)

The used data formats are:

images

var images = [
   {
       width: Integer,
       height: Integer,
       data: compositor-specific
   }
]

layout

var layout = {
    width: Integer,
    height: Integer,
    images: [
        {
            x: Integer,
            y: Integer,
            width: Integer,
            height: Integer,
            data: compositor-specific
        }
    ]
}

For more information of how to write your own modules/functions have a look at the existing ones :-D.

Changelog

See CHANGELOG.md

License

(The MIT License)

Copyright (c) 2013 Stefan Lau [email protected]

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.

node-sprite-generator's People

Contributors

gingerbear avatar jonet avatar mecab avatar ocrest avatar scott-kennedy avatar selaux avatar siemiatj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-sprite-generator's Issues

Bad compositor / incorrect dependencies even though GraphicsMagick is installed

Hey there,
I just got this stack trace on my AppVeyor build all of a sudden - happens intermittently which is confusing:

The Broccoli Plugin: [object Object] failed with:
Error: Either you defined a bad compositor or you dont have the correct dependencies installed.
    at generateSprite (C:\projects\dashboard\node_modules\node-sprite-generator\lib\nsg.js:66:25)
    at C:\projects\dashboard\node_modules\broccoli-sprite\index.js:56:5
    at initializePromise (C:\projects\dashboard\node_modules\rsvp\dist\rsvp.js:589:5)
    at new Promise$1 (C:\projects\dashboard\node_modules\rsvp\dist\rsvp.js:1077:33)
    at BroccoliSprite.updateCache (C:\projects\dashboard\node_modules\broccoli-sprite\index.js:55:17)
    at C:\projects\dashboard\node_modules\broccoli-sprite\node_modules\broccoli-caching-writer\index.js:49:36
    at lib$rsvp$$internal$$tryCatch (C:\projects\dashboard\node_modules\broccoli-sprite\node_modules\broccoli-caching-writer\node_modules\rsvp\dist\rsvp.js:493:16)
    at lib$rsvp$$internal$$invokeCallback (C:\projects\dashboard\node_modules\broccoli-sprite\node_modules\broccoli-caching-writer\node_modules\rsvp\dist\rsvp.js:505:17)
    at C:\projects\dashboard\node_modules\broccoli-sprite\node_modules\broccoli-caching-writer\node_modules\rsvp\dist\rsvp.js:1001:13
    at lib$rsvp$asap$$flush (C:\projects\dashboard\node_modules\broccoli-sprite\node_modules\broccoli-caching-writer\node_modules\rsvp\dist\rsvp.js:1198:9)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

Here's my GraphicsMagick version:

gm version
GraphicsMagick 1.3.25 2016-09-05 Q16 http://www.GraphicsMagick.org/
Copyright (C) 2002-2016 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
  Native Thread Safe       yes
  Large Files (> 32 bit)   yes
  Large Memory (> 32 bit)  yes
  BZIP                     yes
  DPS                      no
  FlashPix                 no
  FreeType                 yes
  Ghostscript (Library)    no
  JBIG                     yes
  JPEG-2000                yes
  JPEG                     yes
  Little CMS               yes
  Loadable Modules         yes
  OpenMP                   yes (200203)
  PNG                      yes
  TIFF                     yes
  TRIO                     no
  UMEM                     no
  WebP                     yes
  WMF                      yes
  X11                      no
  XML                      yes
  ZLIB                     yes
Windows Build Parameters:
  MSVC Version:            1500

Not sure what else could cause this issue besides a bad gm installation, but it seems fine. Any ideas?

0.10.2 version is vulnerable, please publish the GitHub changes to npm ?

The 0.10.2 version published to npm uses the [email protected] package (see its package.json).
This [email protected] version is vulnerable to RegEx (mentionned in this GitHub issue) and fixed it on the [email protected] version.

I know the current package on GitHub has already fixed it by now (๐ŸŽ‰) using the [email protected] package (see its package.json) ... but this change has not been published to npm yet.

It would be nice to publish a new version of the package (like 0.10.3) with these changes.

Replace 0px with 0?

CSSLint dings you on the use of 0px vs 0, would be great to eliminate those warnings from the generated output.

generate spritesheet per pixelRatio

Because of not resizing image based on provided pixelRatio, client is required to load oversize image which is not necessary.

I am willing to send a pull request to cover this for only 'compositor: gm'.
@selaux, please let me know, if this is something you would be willing to accept?

Update canvas dependency version

node-sprite-generator version 0.10.2 depends on canvas 1.3.12.
https://github.com/selaux/node-sprite-generator/blob/0.10.2/package.json#L15

Since canvas 1.3.12 has some issues that have been solved with version 1.6.3:

it would be great to see a new release of node-sprite-generator with an updated canvas version. In the master branch the canvas dependency is already updated:
https://github.com/selaux/node-sprite-generator/blob/master/package.json#L16

Fatal error: write EPIPE

Hi, I can't figure out what causes the following error in my console when I try to run node-sprite-generator from grunt. My task looks the following:

        spriteGenerator: {
            sprite: {
                compositor: 'gm',
                src: [
                    'build/app/images/sprites/*.png'
                ],
                layout: 'diagonal',
                spritePath: 'build/app/images/sprite-node-gen.png',
                stylesheet: 'css',
                stylesheetPath: 'build/app/css/main.css',
                stylesheetOptions:{
                    spritePath: '../images/sprite-node-gen.png'
                }
            }
        },

the spritePath and every other path is valid.

I tracked down where the compositor stops:
https://github.com/selaux/node-sprite-generator/blob/master/lib/compositor/gm.js#L11

But I gave up without solution. Do you have any idea how to proceed?

I'm on osx. ty.

Lighter CSS

Hi

I wrote for myself a custom stylesheet generator which use CSS attributes wildcards
https://github.com/mistic100/angular-smilies/blob/grunt-task/SpriteStylesheet.js

the main advantage is to not redefine the bakground-image for each sprite
I also plan to use common width/height if all dimensions are equals
the drawback is that it requires a non empty prefix

do you think it could be implemented as a new stylesheet ? (I can do a proper pull-request, with template)
also I don't know how to name it :-)

Sprite image and style does not generated

Here is my code:

var nsg = require('node-sprite-generator');
  nsg({
      src: ['images/1.jpg',
        'images/2.jpg',
        'images/3.jpg'
      ],
      spritePath: 'sprite.png',
      stylesheetPath: 'sprite.css',
      stylesheet: 'css'
  }, function (err) {
      console.log('Sprite generated!');
  });

When i run it using node sprite.js It says "Sprite generated!" but nothing happens, there is no sprite.png and no sprite.css!
I'm using vscode internal terminal.

Fails to render custom template... template file name is contents of output stylesheet

For each template type, lib/stylesheet/index.js calls getTemplatedStylesheet once passing in the contents of a file for the respective built in template, and getTemplatedStylesheet then returns a function that is used as renderStylesheet in nsg.js.

However, when using a custom template file,getTemplatedStylesheet is passed the filename instead of the contents of the file.

Update Dependencies

I can no longer compile canvas 1.3.12 on OS X with macports. Canvas 1.6 builds find and seems to work fine generating sprites.

Error installing node-sprite-generator

I am running Windows 10, Node 10.16.2

On running npm install node-sprite-generator, I get this error:

gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Python361\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\t965267\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Delia\node-sprite-gen\node_modules\canvas
gyp ERR! node -v v10.16.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Do I need some other version of python on my machine?

README docs for compressionLevel are misleading for 'gm' compositor

It turns out that the quality() method in the gm node module expects a value between 0-100, rather than 0-9.

Consequently, the default compressionLevel value of 6 for the gm compositor could stand to be bumped considerably. :)

I was confused when I was getting a 1.2 MB spritesheet that ImageOptim was able to shrink to ~140kb. Once I configured node-sprite-generator to use a compressionLevel of 100, it produced a ~140kb spritesheet.

Resolving #6 will allow users to pass their own compressionLevel on to the compositor, but it would probably be a good idea to update the default value and README when you get a chance.

Thanks!

Using additional mixins in LESS

When i generate my LESS file I get some - i hope so - useful variables
@generali-sprites-logo-x: "0";
@generali-sprites-logo-y: "0";
@generali-sprites-logo-width: "113px";
@generali-sprites-logo-height: "91px";

Why these are in string format? In this way I cannot use them for calculations. If I would like to calculate, for example, margin based on image width or height, I have to use image-size native LESS function despite having already the size inside my sprite LESS file.

Why not convert them in number and use interpolation in sprite mixin?

Could not execute GraphicsMagick/ImageMagick

Hi, I was just trying to run the generator but I get the following error:

Error: Could not execute GraphicsMagick/ImageMagick: gm "identify" "-ping" "-format" "%wx%h" "-" this most likely means the gm/convert binaries can't be found
at ChildProcess. (/[PROJECT]/node_modules/gm/lib/command.js:231:12)
at emitOne (events.js:96:13)
at ChildProcess.emit (events.js:188:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:213:12)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

How to Extend

Hi

Sorry if it is a really noob question but how does one extend? I have already looked at the current implementation and know what I need to do. However I need the extend to be clean and live in a separate folder so that it doesn't get overwritten when updating or if doing a "npm install" from fresh.

In particular I want the less output to be somewhat similar to what's here. I know I can get the plugin to produce something similar by having something like the following code but there is a lot of repeated code:

{
stylesheetPath: 'imgs/spriteTest/sprite.less',
stylesheet: 'css',
}

I know I need to tweak the templates/less.tpl but I want it in another directory. Is there a clean way to do it?

Thanks in advance. Cheers.

Options.stylesheet does not accept `javascript`

Hi there,

I'm seeing an error when trying to output javascript styles.

I have tried this with both gm and jimp compositors.

error message:

ENOENT: no such file or directory, open 'javascript'
error Command failed with exit code 1.

config:

{
    src: [path.resolve(__dirname, './assets/spriteable/horizontal/*')],
    spritePath: path.resolve(__dirname, 'assets/__generated__/spritesheet/allbookies-hz.png'),
    stylesheetPath: path.resolve(__dirname, 'assets/__generated__/spritesheet-style/allbookies-hz.js'),
    stylesheet: 'javascript',
    compositor: 'gm',
    compositorOptions: {
      compressionLevel: 6,
    },
  }

package.json:

{
  "name": "org-image",
  "version": "0.86.0",
  "description": "image processing stuff",
  "license": "ISC",
  "main": "lib/org-image.js",
  "scripts": {
    "build": "tsc",
    "postinstall": "cd ../.. && yarn postinstall",
    "postuninstall": "cd ../.. && yarn postinstall",
    "transpile": "npm run build",
    "transpile:watch": "npm run build -- --watch",
    "type-check": "tsc --noEmit"
  },
  "devDependencies": {
    "@types/node-sprite-generator": "^0.10.1",
    "node-sprite-generator": "^0.10.2",
    "ts-node": "8.2.0"
  },
  "bin": {
    "spritesheet": "scripts/spritesheet.sh"
  }
}

Tag a new release with latest fixes?

Would it be possible to tag a new release that includes the recent fixes for #7 and #8?

I have a couple team members that need to be able to pull this down via npm with those fixes intact.

Thanks!

No SASS support?

The documentation mentions support for outputting sass, however it doesn't seem to work?

gm convert: Unrecognized option (-Infinity)

I got the error Unrecognized option when I tried to generate sprites with this options:

            nsg({
                src: [
                    this.config.src + `/*.png`,
                ],
                spritePath: this.config.dest + `/sprite.png`,
                stylesheetPath: this.config.cssDest + `/sprite.css`,
                stylesheet: 'css',
                stylesheetOptions: {
                    prefix: 'icon-',
                },
                compositor: 'gm'
            }, function (err) {
                if(err){
                    throw err;
                }
            });```

Managing trasparent png after node upgrade

After upgrading Node to 0.10.26, generated sprites no longer have transparent background but they have a white background despite original pngs are transparent. Someone with my same problem? Thanks

JPG support with quality option

Why have you removed JPG support? I use jimp composer and in 0.10.2 I can still render image to JPG just by using filename with .jpg extension, but in master I can see there's forced PNG support only (even for .jpg extension a PNG-format file is rendered).

It's useful to have an option to choose the format. For example in my project the example sprite file sizes are:

  1. PNG = 4.7 MB
  2. JPG = 2.6 MB (quality: 100)
  3. JPG = 0.9 MB (quality: 90)

There's no visible quality decrease for these pictures (source images are anyway JPG-s with 90 quality) so I'd like to choose 3rd option with the smallest file.

Also, for 0.10.2 there's no option to provide JPG quality, which I've provided additionally here l0co@7fcd13f

[bug] Cannot read property 'width' of undefined in lib/compositor/gm.js

A callback appears to be invoked without the expected parameters in lib/compositor/gm.js

This is my test file:

    /*globals require*/
    var nodeSpriteGenerator = require('node-sprite-generator');

    var nsgOptions = { src: [ 'public/images/sprites/*.png' ],
      spritePath: 'public/assets/sprites.png',
      stylesheetPath: 'public/assets/sprites.css',
      stylesheet: 'css',
      compositor: 'gm',
      stylesheetOptions: { prefix: 'icon-' }
    };

    console.log('nsgOptions', nsgOptions);
    nodeSpriteGenerator(nsgOptions, function (err) {
        if (!err) {
          console.log('Sprite generated!');
        }
        else {
          console.log('Sprite generation failed:', err);
        }
    });

.. and this is the output that I get when I run it:

    $ node test-nsg.js 
    nsgOptions { src: [ 'public/images/sprites/*.png' ],
      spritePath: 'public/assets/sprites.png',
      stylesheetPath: 'public/assets/sprites.css',
      stylesheet: 'css',
      compositor: 'gm',
      stylesheetOptions: { prefix: 'icon-' } }

    /home/bguiz/code/test-nsg/node_modules/node-sprite-generator/lib/compositor/gm.js:23
                    width: size.width,
                               ^
    TypeError: Cannot read property 'width' of undefined
        at gm.<anonymous> (/home/bguiz/code/test-nsg/node_modules/node-sprite-generator/lib/compositor/gm.js:23:28)
        at gm.EventEmitter.emit (events.js:115:17)
        at gm.<anonymous> (/home/bguiz/code/test-nsg/node_modules/node-sprite-generator/node_modules/gm/lib/getters.js:70:16)
        at ChildProcess.cb (/home/bguiz/code/test-nsg/node_modules/node-sprite-generator/node_modules/gm/lib/command.js:264:16)
        at ChildProcess.EventEmitter.emit (events.js:104:17)
        at Process.ChildProcess._handle.onexit (child_process.js:877:12)
        at child_process.js:1009:20
        at process._tickCallback (node.js:664:11)

Issues when running multiple times in the same process

If nsg is used twice, back to back, in the same process, the 2nd run will inherit some of the modifications of the 1st run. See stylesheetOptions in the two snippets below. These are console.logs from right inside generateSprite and then right after the defaults are applied.

The problem is that stylesheetOptions.spritePath never gets fixed in the 2nd run, so the output Stylus points at the wrong image. It should be pointing at index2 but instead is pointing at index which is leftover from the 1st run.

First run

PASSED IN
{ src: 
   [ 'assets/images/sprite/index/*.png',
     'assets/images/sprite/common/*.png' ],
  spritePath: 'assets/images/index.png',
  stylesheetPath: 'assets/stylesheets/sprite/index.styl' }
OPTIONS AFTER MANIPULATION
{ src: 
   [ 'assets/images/sprite/index/*.png',
     'assets/images/sprite/common/*.png' ],
  spritePath: 'assets/images/index.png',
  stylesheetPath: 'assets/stylesheets/sprite/index.styl',
  layout: 'vertical',
  stylesheet: 'stylus',
  compositor: 'gm',
  layoutOptions: {},
  compositorOptions: {},
  stylesheetOptions: {} }

Second run

OPTIONS BEFORE
{ src: 
   [ 'assets/images/sprite/index2/*.png',
     'assets/images/sprite/common/*.png' ],
  spritePath: 'assets/images/index2.png',
  stylesheetPath: 'assets/stylesheets/sprite/index2.styl' }
OPTIONS AFTER
{ src: 
   [ 'assets/images/sprite/index2/*.png',
     'assets/images/sprite/common/*.png' ],
  spritePath: 'assets/images/index2.png',
  stylesheetPath: 'assets/stylesheets/sprite/index2.styl',
  layout: 'vertical',
  stylesheet: 'stylus',
  compositor: 'gm',
  layoutOptions: { padding: 0 },
  compositorOptions: {},
  stylesheetOptions: 
   { spritePath: '../../images/index.png',
     prefix: '',
     nameMapping: [Function],
     pixelRatio: 1 } }

LESS support

Please support less, it's an easy language and is used more frequently than Stylus.

grunt command line options are not preserved

Would you be able to support the command line arguments passed to this task? I was kinda surprised when --no-write didn't work.

Looking under the hood I see that you are not using grunt.file api to write files.

SASS syntax is incorrect

The SASS output is working now, however there are some syntax issues,

';' is needed at the end of rules and variable declarations
The mixin need to be inclosed by { }

ie it needs to look like this

$top: 0 0 80px 80px;
$top_hover: 0 -80px 80px 80px;
$twitter: 0 -160px 19px 15px;
$up_arrow: 0 -175px 30px 30px;
$youtube: 0 -205px 19px 18px;
@mixin sprite($sprite) {
    background-image: url('img/frontend/sprite.png');
    background-position: nth($sprite, 1) nth($sprite, 2);
    width: nth($sprite, 3);
    height: nth($sprite, 4);
}

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.