magekey / grunt-sprite
Magento2 grunt sprite 生成工具
1.1.3
2018-04-05 20:59 UTC
This package is auto-updated.
Last update: 2024-09-19 15:19:26 UTC
README
Magento 2 Grunt Sprite 工具
基于 Grunt 的 Magento 2 图标精灵生成工具
安装
- 运行
composer require magekey/grunt-sprite - 进入包目录
cd vendor/magekey/grunt-sprite - 运行
npm install - 运行
grunt setup在项目根目录创建便利的符号链接grunt-sprite和配置文件grunt-sprite-config.json.sample。 - 将
grunt-sprite-config.json.sample重命名为grunt-sprite-config.json并定义你的主题
LESS 示例
{
"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 示例
{
"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"
}
}
}
使用方法
cd grunt-sprite
grunt sprite:<sprite>
将精灵添加到你的主题中 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