Figma Support Forum

Provide a manifest property for on publish only

There is a property in the plugin’s manifest called build which lets you specify a shell command to run before the plugin opens. This also gets called when the plugin is published.

Below is an example

// manifest.json
{
  // ...
  "build": "/usr/local/bin/node ./node_modules/.bin/webpack --mode=production"
}

It is/was a solution for ensuring your files have been built before running your plugin during development. It’s usually however more convenient to use the blunder’s development option which will watch for any changes.

There is however a use-case that is quite useful for the build property which, is ensuring that your plugin has been optimised for production before being published. This however has the downside which means optimisation happens every time the plugin is run during development. This causes an unnecessary delay during testing. It also prevents you from isolating commands to happen only when your plugin is published. Some ideas that spring to mind are: the ability to prevent your plugin from accidentally being published unless certain criteria are met, making a request to a server or in my case incrementing the plugin version.

I would like to propose that another property or flag be available to use such as publish which allows plugin creators to run a shell command only when the plugin is published.

This would behave the same as the build property but only occur when the plugin is being published. Alternatively, if there was a way to pass a flag or environment variable this would help too.

In my particular use case I have created a CLI which allows you to increment your plugin’s version number. This version number gets injected into the plugin source code on build. I would like the option to increment this number when the plugin is published, but I would need some context to allow me to do this via the manifest.

It would look something like this:

// manifest.json
{
  // ...
  "publish": "/usr/local/bin/node ./node_modules/.bin/plugma version patch"
}

It would be great to hear of other use cases you think you might have for a buildand/or publish property?

1 Like