Guides & Tutorials

Ignore unnecessary builds to optimize your build times

At Netlify, we try hard to optimize your builds by determining how your site has changed at any given update. To save users from the pain of wasted build minutes, Netlify tries to intelligently check for changes in a site’s base directory. It does this by comparing files in last known version to the latest updated version and automagically skips a build if no change is detected. If you’re keen on learning more about how Netlify skips builds, check out this concise primer on Netlify’s deploy skipping feature

Though Netlify works hard to prevent unnecessary builds, it doesn’t always know when a build is undesired (like in the case of dependabot version bumps). In cases like these, Netlify offers users control over how and what gets built with the ignore setting in the configuration. With this, users have a more fine-grained control over their site builds and can appropriately ignore any and all unnecessary builds.

Ignoring unnecessary builds and updates is as easy as adding an ignore attribute to your configuration like so:

[build]
  ignore = “git diff —quiet HEAD^ HEAD sub_dir/“

If you’re specifically looking to ignore dependabot updates, you can lean on Git log to surface changes in a commit and ignore the build appropriately like so:

[build]
  ignore = "git log -1 --pretty=%B | grep dependabot"

For reference, an exit-code of 1 indicates the contents have changed, while an exit code of 0 indicates that no relevant changes have been detected. As a result, the former will continue the build per usual while the latter will exit the build and return early.

This process of ignoring builds can be incredibly handy when building fast and helps significantly when it comes to conserving your build minutes. For more tips and tricks on optimizing your deployments, head on over to the Netlify Community forum.

Keep reading

Recent posts

How do the best dev and marketing teams work together?