angularbazelangular-json

Referring angular.json in bazel workspace when supplying it in the root workspace is not an option


I am trying to integrate Angular project in an existing Bazel build system. When I try to run angular build, I am getting the following error.

Workspace configuration file (angular.json, .angular.json, workspace.json, .workspace.json) cannot be found in '/home/build/.cache/bazel/_bazel_build/46b74a3c1f9a666f55591a5719d9f2ba/sandbox/linux-sandbox/1/execroot/root' or in parent directories.

Now my angular project is inside a subfolder in the root workspace and so angular is not able to find the angular json file. There is also no option to specify exact location of angular json using args when I run angular build using the architect package of angular devkit which could have potentially solved the problem.

One way, I can think of solving this is copying angular json file to the root of workspace before I run the build command. Is there any other option that I can try?


Solution

  • You can use chdir

    You basically would pass path to that subfolder and the tool will change to that directory before running ng build. I also had to change the outDir by moving up the levels to the root directory for build to success.

    For example, if chdir is lib/sub/angular then outDir would be ../../../$(@D)