• Stars
    star
    300
  • Rank 138,870 (Top 3 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A SketchTool plugin for gulp

gulp-sketch Build Status Stories in Ready

A SketchTool plugin for gulp.

Install

If you're using Sketch.app ver 3.5 or later, just install gulp-sketch via npm:

$ npm install gulp-sketch --save-dev

Are you new to Sketch.app or the user of ver < 3.5 ? See the section below.

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.

For debugging purposes, it has verbose option for additional output

  • verbose: Enables verbose output and outputs stdout from sketchtool (optional, defaults to false)

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/'));
});

Install SketchTool

After the version 3.5, Sketch.app has started bundling sketchtool. You don't have to install it manually. Only the cases below, install sketchtool by yourself.

I'm a developer and not have a license of Sketch.app

Don't worry, the tool doesn't need a license. Run this command to install:

$ npm run install-sketchtool

I'm a user of the older version of Sketch.app (< ver 3.5)

Download SketchTool and install it to your environment by hand.

More Repositories

1

paper-css

Paper CSS for happy printing
CSS
2,443
star
2

symbols-for-sketch

Symbol font templates for Sketch.app
JavaScript
680
star
3

riot-bootstrap

Bootstrap-like Components for Riot.js
JavaScript
136
star
4

felt

On-demand bundler for ES6 / CSS Next
JavaScript
118
star
5

keiyaku-css

Crazy Style Formatter for Japanese Contract Document
CSS
107
star
6

momy

MongoDB to MySQL replication
JavaScript
98
star
7

tokoro

ไฝๆ‰€็ทฏๅบฆ็ตŒๅบฆๅค‰ๆ›ใƒฉใ‚คใƒ–ใƒฉใƒช (ใ‚ธใ‚ชใ‚ณใƒผใƒ‡ใ‚ฃใƒณใ‚ฐ)
CoffeeScript
93
star
8

webdriverio-examples

JavaScript
64
star
9

ikki

An extention toolkit for Riot.js
JavaScript
53
star
10

symbols

The Template of Symbol Fonts for Web
CSS
48
star
11

symbol-font-in-web

CoffeeScript
48
star
12

gulp-slim

Slim plugin for gulp
CoffeeScript
44
star
13

ModernAqua-Theme-for-SugarCRM

MacOSX-like theme by CogniTom
CSS
20
star
14

gulp-straw

Gulp Task Manager: The command-line tool for managing your gulpfile.
CoffeeScript
17
star
15

Qiita

Articles on Qiita
14
star
16

shinkan.today

ใ€Œๆ–ฐๅˆŠใƒˆใ‚ฅใƒ‡ใ‚คใ€
JavaScript
14
star
17

sankaku

ไธ‰่ง’ใ‹ใช้…ๅˆ— โ€• USใ‚ญใƒผใƒœใƒผใƒ‰ใงใ‚ซใƒŠๅ…ฅๅŠ›
12
star
18

sometime-riot

Timepicker for Riot.js
JavaScript
12
star
19

riot-mixin-pack

JavaScript
12
star
20

coder2-docker

Dockerfile
10
star
21

west-or-east

้ƒตไพฟ็•ชๅทใ‹ใ‚‰ใ€่ฅฟๆ—ฅๆœฌใ‹ๆฑๆ—ฅๆœฌใ‚’ๅˆคๅฎš
JavaScript
9
star
22

wdio-phantomjs-service

WebdriverIO service to start & stop PhantomJS
JavaScript
8
star
23

riot-fa

Font Awesome icons for Riot.js
JavaScript
8
star
24

fafgag

Creates an Observable from FAFGAG (Function / Async Function / Generator / Async Generator)
JavaScript
8
star
25

es-http-error

HttpError class for browsers (without Node.js dependencies)
JavaScript
7
star
26

gulp-handbook

gulp.js Handbook
CoffeeScript
7
star
27

electron-starter

Electron Sample Application
CoffeeScript
7
star
28

gulpfiles

gulpfiles for gulp.js
CoffeeScript
6
star
29

gulp-phantom

PhantomJS plugin for gulp
CoffeeScript
6
star
30

comic-viewer

A comic viewer built on Riot.js
JavaScript
6
star
31

riot-action

JavaScript
5
star
32

mornin

Check-in! Mornin'!
JavaScript
5
star
33

dominiq

A happy medium between classic DOMs and upcoming new ES features
JavaScript
5
star
34

CAPITALS

CAPITALS illustrates how to attach source map to the code during compilation.
JavaScript
5
star
35

riotjs-currency-calculator

Riot.js Currency Calculator
CoffeeScript
4
star
36

bookreader.js

JavaScript
4
star
37

EventWall

JavaScript
4
star
38

SugarCE-JLP

Japanese Language Pack for SugarCE
PHP
3
star
39

dotfiles

Dotfiles without dotfiles
Shell
3
star
40

presentation-cmu12

CSS
3
star
41

riot-tutorial

HTML
3
star
42

entry

Sample app with Riot.js
JavaScript
3
star
43

riot-checker

Riot Tag Syntax Checker
HTML
2
star
44

felt-rollup

JavaScript
2
star
45

felt-recipe-minimal

Minimal recipe for Felt
JavaScript
2
star
46

felt-recipe-riot

A recipe for Felt with Riot
JavaScript
2
star
47

felt-recipe-react

A recipe for Felt with React
JavaScript
2
star
48

StaffRoll.net-Libraries-and-Themes

JavaScript
2
star
49

windmill

A keymap for 40% ortholinear keyboards.
C
1
star
50

mb_emulator

PHP
1
star
51

dali-example

JavaScript
1
star
52

CoffeeSugar

Helper functions written in CoffeeScript
1
star
53

Vagrant-LAMP-concrete5

A LAMP stack for Laravel using Vagrant with Chef
Ruby
1
star
54

canvas-lesson

1
star
55

CycleThroughWindows

1
star
56

wagon

Embed images into the CSS on the fly.
PHP
1
star
57

cognitom.github.com

public site
PHP
1
star
58

felt-postcss

JavaScript
1
star
59

devsync

Syncing npm modules while development
JavaScript
1
star