Includes
Includes are similar to references with the key difference, the current work directory. For included build files the current work directory is relative to where it got included.
Includes are ideal to define repetitive tasks and reuse them in multiple places. Reference files can be used to split up tasks, but they keep the current work directory fixed to the directory they are placed. For includes the current work directory is dynamically adjusted to where it got included from.
The following example is a typescript monorepo with two projects a
and b
. Project b
is dependant on a
and both require to keep the dependencies up-to-date before compiling the source code.
For the npm install an include is used, because there is for each project a package.json, but the task definition can be reused.
The include is used for the task dependency of the build task and ensures that the node_modules is installed before.
In the build file of project b
, the include for the npm install task is used as well. An additional reference to a
and a task dependency to a:build ensures that project a
will be built first, before project b
get compiled.
Last updated