create-base-sprite
v1.0.6
Published
Combine icons to generate sprites.
Downloads
21
Readme
说明
对 spritesmith包进行二次封装,在此基础上添加了些自定义参数
使用
- npm install create-base-sprite
- 引入 create-base-sprite,创建对象。注入config
- 调用
runCreate(小图标源路径)
congfig配置选项
const CONFIG = {
outputDir: __dirname + "/output/", // 输出路径
spriteImageName: "sprite.png", // 合成sprite图片名
spriteImageJSON: "sprite.json", // 输出icon信息json文件名
spriteImageCSS: "sprite.css", // 输出css样式文件名
cssImagePrefix: "icons-", // 样式前缀
isOutputTreeJson: false, // 是否输出icon信息文件
unit: "px" // 单位 可选px/vw
};
示例
var Cbsprite = require('create-base-sprite').createSprite
var csprite = new Cbsprite(CONFIG)
csprite.runCreate('./images')
注意
runCreate(url)
该方法会搜集url路径下所有(包括二级、三级文件夹下)小图标- 二次执行会覆盖上一次输出生成的对应文件
- 若出现
canvas
或者canvassmith
包安装错误,请先安装cnpm并使用淘宝镜像npm install -g cnpm --registry=http://registry.npm.taobao.org
,再进行cnpm install
。