Sketch.export¶
Provides support for exporting assets from sketch-documents. More…
Properties¶
Module settings¶
cleanBeforeExport:boolmode:stringListsketchtoolPath:pathworkingDir:string
Export settings¶
background:stringformats:stringListgroupContentsOnly:boolitems:stringListoutputDir:stringoverwrite:boolsaveForWeb:boolscales:varListtrimmed:booluseIdForName:bool
Detailed Description¶
This modules does all the hard job of exporting assets from a sketch document or several of those. It can be used in conjunction with SketchExport or separately with your custom products.
Most probably, you won't touch any of module settings except the exporting mode which defines what actually to export and can be used as following:
orThe export settings give you an ability to set properties for all modes at once. However, you can always override those for a specific mode using corresponding properties from auxiliary modules Sketch.layers, Sketch.artboards, Sketch.pages, and Sketch.preview.
More specific export settings always have the priority. For instance:
Note on common properties
The auxiliary modules have some additional properties specific only to them, so check their documentation for details.
Note on 'preview' mode
The Sketch.preview module provides way less properties comparing to other aux modules. So, any properties set in Sketch.export will be ignored for preview mode if they do not exist in that module.
File Tags¶
Input¶
| Tag | Auto-tagged patterns | Description |
|---|---|---|
sketch |
*.sketch | Sketch documents used as a source for exporting assets. |
Output¶
| Tag | Description |
|---|---|
sketch.export |
Every asset generated by this module is marked with this tag. |
png, jpg, tiff, webp, pdf, eps, svg |
Every exported asset is also marked by a tag that corresponds to its file extension. |
@1x, @2x, @3x, @4x |
Every exported asset is also marked by a tag that corresponds to its scale. |
@1x.9, @2x.9, @3x.9, @4x.9 |
Every exported 9-patch asset is additionally tagged with that corresponds scale with .9 suffix. |
Intermediate¶
Tags used internally
| Tag | Description |
|---|---|
sketch.export-list |
Text file that contains the list of absolute paths of all exported assets. |
Property Documentation¶
background¶
-
Allows to set/override the background color to use when exporting slices. Replaces any background specified in the document.
Allowed values:
- color literal (
'#rgb','#rgba','#rrggbb', or'#rrggbbaa') -
color name
List of all names
Name Color HEX aliceblue #f0f8ffantiquewhite #faebd7aqua #00ffffaquamarine #7fffd4azure #f0ffffbeige #f5f5dcbisque #ffe4c4black #000000blanchedalmond #ffebcdblue #0000ffblueviolet #8a2be2brown #a52a2aburlywood #deb887cadetblue #5f9ea0chartreuse #7fff00chocolate #d2691ecoral #ff7f50cornflowerblue #6495edcornsilk #fff8dccrimson #dc143ccyan #00ffffdarkblue #00008bdarkcyan #008b8bdarkgoldenrod #b8860bdarkgray #a9a9a9darkgreen #006400darkgrey #a9a9a9darkkhaki #bdb76bdarkmagenta #8b008bdarkolivegreen #556b2fdarkorange #ff8c00darkorchid #9932ccdarkred #8b0000darksalmon #e9967adarkseagreen #8fbc8fdarkslateblue #483d8bdarkslategray #2f4f4fdarkslategrey #2f4f4fdarkturquoise #00ced1darkviolet #9400d3deeppink #ff1493deepskyblue #00bfffdimgray #696969dimgrey #696969dodgerblue #1e90fffirebrick #b22222floralwhite #fffaf0forestgreen #228b22fuchsia #ff00ffgainsboro #dcdcdcghostwhite #f8f8ffgold #ffd700goldenrod #daa520gray #808080green #008000greenyellow #adff2fgrey #808080honeydew #f0fff0hotpink #ff69b4indianred #cd5c5cindigo #4b0082ivory #fffff0khaki #f0e68clavender #e6e6falavenderblush #fff0f5lawngreen #7cfc00lemonchiffon #fffacdlightblue #add8e6lightcoral #f08080lightcyan #e0fffflightgoldenrodyellow #fafad2lightgray #d3d3d3lightgreen #90ee90lightgrey #d3d3d3lightpink #ffb6c1lightsalmon #ffa07alightseagreen #20b2aalightskyblue #87cefalightslategray #778899lightslategrey #778899lightsteelblue #b0c4delightyellow #ffffe0lime #00ff00limegreen #32cd32linen #faf0e6magenta #ff00ffmaroon #800000mediumaquamarine #66cdaamediumblue #0000cdmediumorchid #ba55d3mediumpurple #9370dbmediumseagreen #3cb371mediumslateblue #7b68eemediumspringgreen #00fa9amediumturquoise #48d1ccmediumvioletred #c71585midnightblue #191970mintcream #f5fffamistyrose #ffe4e1moccasin #ffe4b5navajowhite #ffdeadnavy #000080oldlace #fdf5e6olive #808000olivedrab #6b8e23orange #ffa500orangered #ff4500orchid #da70d6palegoldenrod #eee8aapalegreen #98fb98paleturquoise #afeeeepalevioletred #db7093papayawhip #ffefd5peachpuff #ffdab9peru #cd853fpink #ffc0cbplum #dda0ddpowderblue #b0e0e6purple #800080red #ff0000rosybrown #bc8f8froyalblue #4169e1saddlebrown #8b4513salmon #fa8072sandybrown #f4a460seagreen #2e8b57seashell #fff5eesienna #a0522dsilver #c0c0c0skyblue #87ceebslateblue #6a5acdslategray #708090slategrey #708090snow #fffafaspringgreen #00ff7fsteelblue #4682b4tan #d2b48cteal #008080thistle #d8bfd8tomato #ff6347turquoise #40e0d0violet #ee82eewheat #f5deb3white #ffffffwhitesmoke #f5f5f5yellow #ffff00yellowgreen #9acd32 -
rgb/rgbafunctionFor example:
'rgb(128, 0, 255)','rgba(50%, 0, 100%, 50%)'. -
hsl/hslafunctionFor example:
'hsl(270deg, 100%, 50%)','hsla(270, 100, 50, 0.5)'
Default:
undefined - color literal (
cleanBeforeExport¶
-
Specifies whether to clean the output folder before each new export.
Default:
true
formats¶
-
The format in which assets are generated. If you set this value, it will override your export presets in the documents.
Preview format
In the
'preview'mode, the images are always generated in PNG format.Tip
If empty list is provided, then the default sketchtool's behavior is used. In
'layers'mode it generates assets according to the exporting presets set in documents. In other modes, it generates PNG by default.Allowed values:
'png'|'jpg'|'tiff'|'webp'|'pdf'|'eps'|'svg'Default:
[]
groupContentsOnly¶
-
Export only layers that are contained within the group.
Default:
false
items¶
-
List of artboard/slice names or IDs to export. You can retrieve the IDs from the metadata. If you specify this value, it will override the export presets defined in the document.
Tip
If empty list is provided, then the default sketchtool's behavior is used which is to generate assets for all exportable artboards/slices.
Default:
[]
mode¶
-
Gives an ability to choose what to export. You can specify either a single value or a list.
Allowed values:
'layers'|'artboards'|'pages'|'preview'Default:
'layers'
outputDir¶
-
If you set this property, the assets are exported to folder with this name relatively to
workingDir. In other words, the resulting filename is prepended byoutputDir/.Default:
undefined
overwrite¶
-
Set this to true to allow to overwrite existing files with newly generated once.
I couldn't make it work
I tried this parameter with the sketchtool, however, it had no influence. Maybe it doesn't work or maybe I did something wrong.
Default:
false
saveForWeb¶
-
Export web-ready images. Setting this option to
truestrips out additional file data from some images, such as EXIF metadata and color profiles.Default:
false
scales¶
-
Scales to be used for exporting of assets. This allows you to scale pictures up (@2x, @3x, @4x, etc.) or down (@0.5x, @0.25x, etc.). You can provide a single value or a list. If you specify this value, it will override the export presets defined in the document.
Floating-point scaling factor
It appears that sketchtool allows to use floats only when scaling down, i.e. for \(0 < scale < 1\). If you try to set this property to something like 2.5, the fractional part is trancated.
Tip
If empty list is provided, then the default sketchtool's behavior is used: all assets are exported according to the presets defined in the document or as
@1x.Default:
[]
sketchtoolPath¶
-
The path to the
sketchtoolthat will be used for exporting. Usually, there is no need to change this value.Default: the binary from the first found Sketch.app installed in your system.
trimmed¶
-
Export images trimmed.
Default:
false
useIdForName¶
-
Name exported images using their ID rather than their name.
You can also retrieve the IDs from the metadata.
Default:
false
workingDir¶
- Contains the path to the export working directory. Useful when you want to install generated files preserving the folder structure.