Now available: configure Build Plugins by deploy context

We’re excited to announce that you can now configure your build plugins by deploy context.

As a refresher, deploy contexts refer to the different types of deploys of your site on Netlify, including production deploys to your primary site URL, Deploy Previews, and branch deploys built from a specific branch of your site repository.

With this new feature, you can choose which plugins run in each context, and configure plugins to run with different inputs per context.

Enable Build Plugins by deploy context

You can now limit a Build Plugin to run in a certain deploy context only.
Here’s an example configuration that runs the Sitemap plugin in the context of production deploys only.

package = "@netlify/plugin-sitemap"

Since plugins installed from the plugins directory run in all deploy contexts, please ensure that context-specific plugins are using file-based installation instead.

Configure Build Plugins by deploy context

You can also configure a plugin’s inputs settings differently per context.
Here’s an example configuration that runs the Cypress plugin differently based on deploy contexts.

package = "netlify-plugin-cypress"
  record = true

package = "netlify-plugin-cypress"
  record = false

You can find out more in the docs:

This was the issue with the most :+1: in the netlify/build repository, so we’re looking forward to finding out how folks end up using it. Feel free to share your config in the thread so others can learn!