0

I want to compile a new js folder for each script folder. Is that possible with tsconfig.json?

Directories

folder1
  scripts
    index.ts

folder2
  scripts
   index.ts
tsconfig.json

Directories after compile

folder1
  scripts
    index.ts
  js
    index.js

folder2
  scripts
    index.ts
  js
    index.js
tsconfig.json
1
  • For now I'm using a tsconfig.json file for each directory... EDIT: no that didn't work... Commented Oct 29, 2019 at 8:08

1 Answer 1

1

Disclaimer... this doesn't answer your question specifically, because what you want to do breaks with convention. Even if you manage to do it your way, I think you'll find the pain will outweigh the benefit.

The simplest way is to specify an outDir output directory. Your existing folder structure will be maintained in the output directory, with all the JavaScript and TypeScript kept cleanly separated.

{
    "compilerOptions": {
        "outDir": "./scripts",
        ...
    }
}

So if you start with:

/component-a
    index.ts
/component-b
    index.ts

You'll end up with the folders mirrored in the output directory.

/component-a
    index.ts
/component-b
    index.ts
/scripts
    /component-a
        index.js
    /component-b
        index.js

Unless you plan to deploy both (?) you don't normally want the TypeScript and JavaScript intermingled.

Sign up to request clarification or add additional context in comments.

1 Comment

Is there a way to not get scripts folder in my js folder. When I compile it looks like this: /js/folder1/scripts/index.js; I want it to look like this: /js/folder1/index.js;

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.