Git Product home page Git Product logo

easy-svg's Introduction

easy-svg Build Status

A tiny plugin to help with the svg + use workflow

Install

npm install easy-svg

Usage

There's a through stream bundled, use with vinyl-fs

var vfs     = require('vinyl-fs');
var easysvg = require('easy-svg');

vfs.src('svg/*.svg')
    .pipe(easysvg.stream())
    .pipe(vfs.dest("./out"));

Or with gulp

var gulp    = require('gulp');
var easysvg = require('easy-svg');

gulp.task('svg', function() {

    return gulp.src('svg/*.svg')
        .pipe(easysvg.stream())
        .pipe(gulp.dest("./out"));
});

Or directly from the file system

var fs  = require('fs');
var easysvg = require('easy-svg');

var builder = easysvg.create();

builder.add({key: './fixtures/bin.svg', content: fs.readFileSync('./svg/bin.svg', 'utf-8')});
builder.add({key: './fixtures/book.svg', content: fs.readFileSync('./svg/book.svg', 'utf-8')});

builder.compile().then(function (out) {
    fs.writeFileSync('./icons.svg', out);
}).catch(function (err) {
    console.error(err);
});

Options.

By default, 3 files will be produced

  1. icons.svg - the compiled svg containing all of your SVG files
  2. svgforeveyrone.min.js - For IE 9 support
  3. preview.html - For a preview of what was create

To disable any of theme:

var vfs     = require('vinyl-fs');
var easysvg = require('easy-svg');

vfs.src('svg/*.svg')
    .pipe(easysvg.stream({
        js: false,
        preview: false
    }))
    .pipe(vfs.dest("./out"));

To change any file names:

var vfs     = require('vinyl-fs');
var easysvg = require('easy-svg');

vfs.src('svg/*.svg')
    .pipe(easysvg.stream({
        js: 'js/ie9.js'
    }))
    .pipe(vfs.dest("./out"));

Contributing.

This module is authored in ES6, so you should only edit files withing the src directory and compile using npm run es6. Alternatively, to compile on every file save, run npm run es6-watch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.