magekey/grunt-sprite

Magento2 grunt sprite generation tool

Installs: 7 716

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 2

Open Issues: 0

Language:HTML

Type:magento2-component

1.1.3 2018-04-05 20:59 UTC

This package is auto-updated.

Last update: 2024-12-19 15:49:23 UTC


README

Travis branch Packagist Packagist

Magento 2 Grunt Sprite Tool

Sprite Generation for Magento 2, based on Grunt

Installation

  1. Run composer require magekey/grunt-sprite
  2. Go to package directory cd vendor/magekey/grunt-sprite
  3. Run npm install
  4. Run grunt setup create a convenient symlink grunt-sprite and config file grunt-sprite-config.json.sample in the project root.
  5. Rename grunt-sprite-config.json.sample to grunt-sprite-config.json and define your themes

LESS Example:

{
  "path": {
    "sprite_mytheme": "<%= project %>/app/design/frontend/Vendor/mytheme/web"
  },
  "sprite": {
    "mytheme": {
      "src": "<%= sprite_mytheme %>/images/sprite/*.png",
      "dest": "<%= sprite_mytheme %>/images/sprite.png",
      "destCss": "<%= sprite_mytheme %>/css/source/_sprite.less"
    }
  }
}

SCSS Example:

{
  "path": {
    "sprite_mymodule": "<%= project %>/app/design/frontend/Vendor/mytheme"
  },
  "sprite": {
    "test_module": {
      "src": "<%= sprite_mymodule %>/MyPackage_Module/web/images/sprite/*.png",
      "dest": "<%= sprite_mymodule %>/MyPackage_Module/web/images/sprite.png",
      "destCss": "<%= sprite_mymodule %>/MyPackage_Module/web/scss/_sprite.scss",
      "cssTemplate": "<%= src %>/templates/scss.template.handlebars"
    }
  }
}

Usage

cd grunt-sprite
grunt sprite:<sprite>

Add sprites to your theme in app/design/Vendor/theme/web/css/_styles.less

@import 'source/lib/_lib.less'; // Global lib
@import 'source/_sources.less'; // Theme styles
@import 'source/_components.less'; // Components styles (modal/sliding panel)

// Add new line to import sprites
@import 'source/_sprite.less'; // Sprites