GithubHelp home page GithubHelp logo

gulp-sketch's Introduction

gulp-sketch Build Status Stories in Ready

A SketchTool plugin for gulp.

Install

Download SketchTool and install it to your environment by hand or by using the script below.

$ curl -L https://raw.githubusercontent.com/cognitom/dotfiles/master/lib/sketchtool.sh | sudo sh

Then, install gulp-sketch plugin via npm.

$ npm install gulp-sketch --save-dev

Usage

var gulp   = require('gulp');
var sketch = require('gulp-sketch');

gulp.task('sketch', function(){
  return gulp.src('./src/sketch/*.sketch')
    .pipe(sketch({
      export: 'slices',
      formats: 'png'
    }))
    .pipe(gulp.dest('./dist/images/'));
});

or write it in CoffeeScript.

gulp   = require 'gulp'
sketch = require 'gulp-sketch'

gulp.task 'sketch', ->
  gulp.src './src/sketch/*.sketch'
  .pipe sketch
    export: 'slices'
    formats: 'png'
  .pipe gulp.dest './dist/images/'

Options

The options are the same as what's supported by SketchTool.

  • export: pages,artboards,slices
  • formats: png,jpg,pdf,eps,svg
  • scales: 1.0,2.0
  • items: List of artboard/slice names or ids to export. The default is to export all artboards/slices (optional).
  • bounds:
  • saveForWeb: Export web-ready images (optional, defaults to NO).
  • compact: Export in compact form. Currently only relevant for SVG export. (optional, defaults to NO).
  • trimmed: Export images trimmed. (optional, defaults to NO).

Additionally, it has clean option for exporting SVG.

  • clean: Remove Sketch namespaces and metadata from SVG (optional, defaults to NO). See clean-sketch.

Layer Naming

When exporting slices, the name of layer is the key to decide the name of the file exported.

  • If you have the layer named yellow and export it with option { format:'png' }, the exported file would be yellow.png.
  • If you have the layer named square/yellow and export it with same option, the file would be exported as yellow.png under square/ directory.

Layer Naming

Bohemian Coding mentioned about it in their article.

You can give each of your slices their own name, and this is the name that will be used when you save your slice to disk. A neat trick is that you if you include a slash (a '/') it will create subfolders for your first. For example, if you named your slice foo/bar.png, it would first create a folder named 'foo' and then create a image named 'bar.png' in there.

Should include or not include generated files?

Basically not. But sometimes it would be controversial. Because tools like sketchtool depends on the environment. Especially Windows user can't use sketchtool.

  • All members in the team use Mac? - Force to install sketchtool. It's free!
  • Most of members in the team use Mac? - Force to install sketchtool. Make sketch-related tasks skippable for Windows user.
  • Only a designer uses Mac? - Include generated design works and make sketch-related tasks optional.

How to skip a task for Windows user

Check sketchtool exists by npm-which.

var gulp   = require('gulp');
var sketch = require('gulp-sketch');
var gutil  = require('gulp-util')
var which  = require('npm-which')(__dirname);

gulp.task('sketch', function(){
  try {
    which.sync('sketchtool');
  } catch(error){
    gutil.log(error); return;
  }
    
  return gulp.src('./src/sketch/*.sketch')
    .pipe(sketch({
      export: 'slices',
      formats: 'png'
    }))
    .pipe(gulp.dest('./dist/images/'));
});

gulp-sketch's People

Contributors

cognitom avatar zethussuen avatar caseyyee avatar seidtgeist avatar

Watchers

James Cloos avatar Adam Sax avatar

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.