Last active
April 16, 2016 23:58
-
-
Save kennethlynne/30dafef6ff2f3bb2ea6babd08fea364a to your computer and use it in GitHub Desktop.
export png from artboards and slices in sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var sketch = require('gulp-sketch'); | |
var argv = require('yargs').argv; | |
var del = require('del'); | |
var runSequence = require('run-sequence'); | |
var outputDir = './output/'; | |
if (!argv && argv.path) { | |
throw new Error('path argument missing'); | |
} | |
var inputGlob = argv.path; | |
gulp.task('clean', function () { | |
del([outputDir + '/**/*']); | |
}); | |
gulp.task('exportSlices', function () { | |
return gulp.src(inputGlob) | |
.pipe(sketch({ | |
export: 'slices', | |
formats: 'png' | |
})) | |
.pipe(gulp.dest(outputDir)); | |
}); | |
gulp.task('exportArtboards', function () { | |
return gulp.src(inputGlob) | |
.pipe(sketch({ | |
export: 'artboards', | |
formats: 'png' | |
})) | |
.pipe(gulp.dest(outputDir)); | |
}); | |
gulp.task('default', ['export'], function () { | |
gulp.watch(inputGlob, ['export']); | |
}); | |
gulp.task('export', function (cb) { | |
runSequence(['clean', 'exportArtboards', 'exportSlices'], cb); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment