You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When gulp-sketch exports images, it does not use the original path of the sketch file when deciding where to save the exported versions. This causes problems in a project which has its sketch files in various locations in a project. So, if we had this structure:
components
component1
component1.sketch
component2
component2.sketch
component3
component3.sketch
Then when the images are created, if we set up gulp-sketch to store exports in exports, then they get saved like this:
exports
component1.png
component2.png
component3.png
when instead we would want this:
exports
component1
component1.png
component2
component2.png
component3
component3.png
As a workaround, I set up our gulp task like this:
constpath=require('path');consttap=require('gulp-tap');constgulp=require('gulp-help')(require('gulp'));constsketch=require('gulp-sketch');/** * Export images from a sketch file */gulp.task('sketch',function(){letdest;returngulp.src('./src/**/*.sketch').pipe(tap((file)=>{// gulp-sketch strips out destination pathdest=path.dirname(path.join(file.base,path.relative(file.base,file.path)));returnfile;})).pipe(sketch({export: 'slices',formats: 'png',})).pipe(gulp.dest((file)=>{return`${dest}/sketch-export/`;}));});
The above task then requires the dest variable, created during the flow, to be able to achieve the same directory structure as our app. I do this so that the exported images live in the same directory as the .sketch file, in a subdirectory called sketch-export.
It would be great if there was an option to allow maintaining/recreating the original directory structure in which the sketch files are located.
The text was updated successfully, but these errors were encountered:
Hi @cognitom,
When gulp-sketch exports images, it does not use the original path of the sketch file when deciding where to save the exported versions. This causes problems in a project which has its sketch files in various locations in a project. So, if we had this structure:
Then when the images are created, if we set up gulp-sketch to store exports in
exports
, then they get saved like this:when instead we would want this:
As a workaround, I set up our gulp task like this:
The above task then requires the
dest
variable, created during the flow, to be able to achieve the same directory structure as our app. I do this so that the exported images live in the same directory as the .sketch file, in a subdirectory calledsketch-export
.It would be great if there was an option to allow maintaining/recreating the original directory structure in which the sketch files are located.
The text was updated successfully, but these errors were encountered: