magekey / grunt-sprite
Magento2 grunt sprite generation tool
Installs: 7 604
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 2
Open Issues: 0
Language:HTML
Type:magento2-component
This package is auto-updated.
Last update: 2024-11-19 15:43:36 UTC
README
Magento 2 Grunt Sprite Tool
Sprite Generation for Magento 2, based on Grunt
Installation
- Run
composer require magekey/grunt-sprite
- Go to package directory
cd vendor/magekey/grunt-sprite
- Run
npm install
- Run
grunt setup
create a convenient symlinkgrunt-sprite
and config filegrunt-sprite-config.json.sample
in the project root. - Rename
grunt-sprite-config.json.sample
togrunt-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