Details
-
Technical task
-
Resolution: Done
-
P1: Critical
-
None
Description
Find the workflow and technical requirements to create the Sketch plugin.
Findings:-
Writing/Reading metadata:
https://developer.sketchapp.com/reference/api/#settings
var Settings = require('sketch/settings')
Document wide metadata Settings.globalSettingForKey('my-key') & Settings.setGlobalSettingForKey('my-key', 0.1)
Layer metadata Settings.layerSettingForKey(layer, 'my-key') & Settings.setLayerSettingForKey(layer, 'my-key', 0.1)
Exporting assets:
https://developer.sketchapp.com/reference/api/#export-format
https://developer.sketchapp.com/reference/api/#export
var sketch = require('sketch/dom') sketch.export(layer, \{ formats: 'svg', }) sketch.export([layer, layer2]) const options = \{ scales: '1, 2, 3', formats: 'png, jpg' } sketch.export(page, options) sketch.export(document.pages) const options = \{ formats: 'json', output: false } const sketchJSON = sketch.export(layer, options)
Other:
- Use web pack and skpm build to deploy the extra JS files and resources, otherwise api's can not be exposed from webview and commands.
- Use require in the command js for the lazy load resources and JS. Webpack only deploys the resources being used in the html/JS.