Do More at Build Time with Build Plugins
Tags: netlify, development, workflow
Published: 2022-01-03 04:04:37

---
title: Do More at Build Time with Build Plugins
published: true
description: You can't buy time but you can make the most of it by automating tasks during build time with Netlify Build Plugins.
tags: Netlify, Development, Workflow
cover_image: https://ph-files.imgix.net/41a03c58-0a25-4a6e-9112-39678713af74.png?auto=format&fit=crop
canonical_url: https://www.netlify.com/blog/2021/12/27/do-more-at-build-time-with-build-plugins/
series: Netlify - a feature a day 2021
---
> Throughout December we'll be [highlighting a different Netlify feature each day](https://www.netlify.com/blog/2021/12/01/highlighting-a-different-netlify-feature-each-day-in-december/?utm_campaign=featdaily21&utm_source=netlify&utm_medium=blog&utm_content=build-plugins). It might just be the thing you need to unlock those creative juices, and [dust off that domain](https://www.netlify.com/blog/2021/12/01/dusty-domains-your-forgotten-domains-raise-money-for-charity/?utm_campaign=featdaily21&utm_source=netlify&utm_medium=blog&utm_content=build-plugins) you registered but never deployed! Keep an eye [on the blog](https://www.netlify.com/blog/2021/12/01/highlighting-a-different-netlify-feature-each-day-in-december/?utm_campaign=featdaily21&utm_source=netlify&utm_medium=blog&utm_content=build-plugins) and on [Twitter](https://twitter.com/netlify) for each feature!
On engineering teams and in life, in general, time tends to be the most valuable yet least plentiful resource. Since [studies have proven that us humans cannot multitask](https://hbr.org/2010/12/you-cant-multi-task-so-stop-tr), we must find another way to do many things at once. May I introduce [build plugins](https://www.netlify.com/products/build/plugins/).

Build plugins are little utilities that you can install [through your project dashboard](http://app.netlify.com/plugins) that help with caching, optimizations, security, and a ton more. So when you run your build it can run your tests while you run to get lunch. Yay, more things at once! You can check out the whole list [in the plugins dashboard](http://app.netlify.com/plugins).

![screenshot of the plugins list page](https://cdn.netlify.com/1c53bcc4a9391f2c01735f4e9ed1e464082ac4ce/6e4c0/img/blog/screen-shot-2021-12-28-at-10.49.08-am.png)

## Customize Your Workflow

Can you think of some tedious task that you have to take on _every time_ you deploy? Have to check your Lighthouse score, optimize images, run Cypress end-to-end tests? Well, there _are_ build plugins for that BUT what if there wasn't 😱?! No worries, you can spin up your own 🥳.

There are two parts to a Build Plugin: the `.yml` file for the plugins meta data and any `.js` files you need to make it do what you need. Then you can pull it into your projects with your `netlify.toml` configuration file. With plugins you can add functionality to each part of the build processes:

- __`onPreBuild`__: runs before the build command is executed.
- __`onBuild`__: runs directly after the build command is executed and before Functions bundling and Edge Handlers bundling.
- __`onPostBuild`__: runs after the build command completes; after onBuild tasks, Functions bundling, and Edge Handlers bundling are executed; and before the deploy stage. Can be used to prevent a build from being deployed.
- __`onError`__: runs when an error occurs in the build or deploy stage, failing the build. Can’t be used to prevent a build from being deployed.
- __`onSuccess`__: runs when the deploy succeeds. Can’t be used to prevent a build from being deployed.
- __`onEnd`__: runs after completion of the deploy stage, regardless of build error or success; is useful for resources cleanup. Can’t be used to prevent a build from being deployed.

Learn more about [creating your own Build Plugins](https://docs.netlify.com/configure-builds/build-plugins/create-plugins) in our documentation. Happy coding 👩🏻‍💻!

### Resources for the Road
- [Netlify Build Plugin Documentation](https://docs.netlify.com/configure-builds/build-plugins/)
- [One-click install Build Plugins](http://app.netlify.com/plugins)
- [Creating Build Plugins](https://docs.netlify.com/configure-builds/build-plugins/create-plugins)
- [Top Ten Build Plugins](https://www.netlify.com/blog/2021/01/25/top-10-netlify-build-plugins-2021-update/)
- [Many more blog posts on Build Plugins!](https://www.netlify.com/tags/build-plugins/)