项目作者: VKCOM

项目描述 :
Module for generate SVG sprites and PNG fallback
高级语言: JavaScript
项目地址: git://github.com/VKCOM/sprites.git
创建时间: 2019-04-09T08:45:09Z
项目社区:https://github.com/VKCOM/sprites

开源协议:MIT License

下载


@vkontakte/sprites

@vkontakte/sprites.svg" alt="Module version badge">
License badge
@vkontakte/sprites.svg" alt="Minimum Node.JS version badge">

Module for generate SVG sprites and PNG fallback that used in m.vk.com

Requirements

Inkscape (>= 0.91)

Node.JS (>= 8)

Install

npm install @vkontakte/sprites or yarn add @vkontakte/sprites

Demo

See demo/index.js

Generating

To generate Sprites you just need to run

generate(path, output = {}, converter, options)

  • path is place on your filesystem where module loads SVG icons
  • converter see PNG Fallback section

PNG Fallback

In this time there is single PNG converter Inkscape, but you can PR your if you need. It is simple, you just need to extend BaseConverter

To create PNG converter you need to import it

const InkscapeConverter = require("@vkontakte/sprites/src/convert/InkscapeConverter")

Then create new instance of Converter

const converter = new InkscapeConverter([1, 2], pngPath, "/opt/local/bin/inkscape"),

And use as param for generating sprites