Search code examples
angulartypescriptcompilationtsconfig

How can we have multiple tsconfig file for angular app


As per the customer requirement, we need to have two separate applications(link is there will be navigation from appA to appB) in one single package to make the deployment easier.

But there comes the issue, one section is (typescript with jquery)and another is built in angular.

So while combining both , we can use only one tsconfig. Any possibilities to specify different tsconfig path for each app.

Like, tsconfig1.json -> appA tsconfig2.json -> appB


Solution

  • Any tsconfig file can include an extends property which can be used to add customisation on top of a base configuration:

    https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#configuration-inheritance-with-extends

    Alternatively in package.json you could define specific scripts, e.g.

    {
      build:appA="cp tsconfig.a.json tsconfig.json && npm run build"
      build:appB="cp tsconfig.a.json tsconfig.json && npm run build"
    }