jcons

1.1.1 • Public • Published

jcons

npm version

jcons optimizes your SVG files and compiles them to a JSON file. This enables you to use your SVGs inline in your HTML.

Usage

    [sudo] npm install jcons -g
    Usage: jcons [options]

    SVG to JSON

    Options:

        -h, --help              output usage information
        -V, --version           output the version number
        -o, --output <path>     Specifies the output file or directory
        -r, --recursive         Recursively find svg files, when a directory is specified
        --spaces [number]       Number of spaces to format the JSON output file
        --remove-colors         Removes the "fill" attributes from the svg strings
        --remove-view-box       Removes the "view-box" attributes from the svg strings
        --remove-xml-proc-inst  Removes the xml processing instructions from the svg strings

As stream (node)

    myStream.pipe(jcons({
        // options
    }));

Options

Key Type Default
spaces Number 2
removeColors Boolean false
removeViewBox Boolean false
removeXMLProcInst Boolean false

In Gulp

var jcons = require('../');

gulp.src(__dirname + '/svg/*.svg')
    .pipe(jcons({
        // options
    }))
    .pipe(gulp.dest('out.json'));

Custom use

var svgs = [{
    name: 'arrow-down',
    contents: '<?xml ... ?><svg>...</svg>' // <-- raw svg content
}, {...}, {...}, {...}];

jcons.svgsToObject(svgs, options, function(err, output) {
    // output available here
});

// Or synchronous style
var output = jcons.svgsToObjectSync(svgs, options);

Release History

  • 1.1.1 Command help fix
  • 1.1.0 Added jcons cli functionality
  • 1.0.1 Add jcons.svgsToObject() and its synchronous equivalent
  • 1.0.0 Rewrite the plugin to use streams
  • 0.0.6 Generate all icons and add single icon functionality
  • 0.0.5a Remove lodash and improve code readability
  • 0.0.5 Made jconfig.json optional, added runtime config option
  • 0.0.3 Gulp support
  • 0.0.1 Initial release

Package Sidebar

Install

npm i jcons

Weekly Downloads

0

Version

1.1.1

License

ISC

Last publish

Collaborators

  • andreleon
  • jessedvrs