0

What I need? I want a convenient and easy way to create configuration for an Angular application (which is described in the angular.json file) on the fly. The same way this is done, for example, with Webpack or Tailwind configs (their configs can be .js files that simply export the config as an object).

Why is this necessary? It so happened that my project has a lot of build configurations. Therefore, the angular.json file becomes simply huge and very difficult to maintain. Many parts of the config are repeated, because some blocks (for example, fileReplacements and assets) have to be written in full each time, because angular.json does not have a mechanism for inheriting configurations.

How do I solve the problem now? I simply created a .ts script that creates the angular.json file I need. And I run this file before each ng build or ng serve command. There are a couple of disadvantages to this approach.

  1. For the Angular configuration, there is not even TypeScript typing for the hints to work.
  2. Every time the configuration changes, I have to manually stop and rebuild the application from scratch. Although if you change angular.json directly, then Angular sees this change and rebuilds the application on the fly.

Is there an adequate solution for this problem? Maybe a more elegant way? Maybe it is possible to use the angular.js file instead of angular.json in some native way, but this is not in the documentation?

asked Jan 19, 2024 at 5:55
2
  • maybe this will help you Commented Jan 19, 2024 at 13:22
  • @oksd Thank you! But this is exactly the same way I'm currently solving this problem. I'm looking for a slightly more delicate and beautiful way. Commented Jan 21, 2024 at 13:02

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.