Debug and test a build event handler
While developing your build event handler, you can test it locally to check if it works as expected.
Prepare your test project
Section titled “Prepare your test project”To get ready to test your build event handler locally, do the following:
- Have a test project repository and your extension repository on your local machine.
- Create a test project on Netlify.
- Install the Netlify CLI with
npm install netlify-cli -g. - Make sure your test project is a git repository by running
git initin the root of your test project. - Log in to your Netlify account with
netlify login. - Link your local test project to the test project you created on Netlify by running
netlify link. - Create a
netlify.tomlfile in the root of your test project with the following configuration:
[[integrations]]name = "my-extension"
[integrations.dev]path = "../path/to/extension/repository"Test locally on your test project
Section titled “Test locally on your test project”Now that your test project is ready, you can test your extension’s build event handler locally. To do so, run the following command for your test project in your terminal:
netlify build --context=devThis runs a build of your test project while using your extension’s build event handler. You can now make changes to your extension’s build event handler and check the results in your terminal whenever you run the command above. Any console.log statements will show in the local build log.
Next steps
Section titled “Next steps”When you’re ready, you can publish your extension as a private extension and test it with a project in production.