Custom ignore build commands - using public npm modules

Hello Netlify team! Thank you so much for such an incredible service!

I am trying to put together an example of how to use Netlify with Monorepos managed by Nx.

And I need to use a custom “ignore build” command. Is there a way to use npm modules in the ignore command?

The reason I want to use Nx is that it knows about my repo’s dependency graph and allows me to determine whether a specific project (or any of its dependencies) has changed between commits. Nx offers a super simple command to determine this: nx print-affected --base=HEAD~ --head=HEAD

Is there a way to use the “nx CLI” in the ignore command? (the npm modules get installed after the ignore command runs unfortunately)

build:
  ignore: nx print-affected --base=HEAD~ --head=HEAD

(the above command won’t be the final command that I will use, as I need to parse what it returns, and return a code 0 or 1 based on that, but for now, I just need to get it running)


If this is possible, then how could I see why the above is failing? On the “deploy” logs it hides any error output.

I just realised I don’t have access to yarn or even node at the “build ignore” stage

I am currently failing the build in the “preinstall” step, using “yarn exec” to execute npm modules without installing them. However, the problem here is that it Fails the build when I return an exit code 1.

Is there a way to just cancel the build? Maybe I can use a specific exit code?

Hey @rarmatei, we currently don’t support custom “ignore build” commands. I believe the current command is basically a flag that’s sent- if there’s no flag, we don’t build. Correction: We do support custom “ignore build” commands!

No npm modules will be available at that point though. However, you may want to sign up for our Build Plugins beta and see if you can accomplish what you want that way:

Netlify Build Plugins extend the functionality of the Netlify Build process. You can install plugins made by others, or write your own.

Let us know if you go that route and if we can answer any other questions on this!

You can write a build plugin that cancels the build using the utils.build.cancel() method: GitHub - netlify/build: Netlify Build runs the build command, Build Plugins and bundles Netlify Functions.

Build plugins run after dependencies are installed :+1: