How can I compile different files to different folders, in TypeScript?
Picture this: I've got main.ts
and sw.ts
.
How can I compile main.ts
to js/
folder and sw.ts
to root
directory? Can you give me an example?
typescript
add a comment |
Picture this: I've got main.ts
and sw.ts
.
How can I compile main.ts
to js/
folder and sw.ts
to root
directory? Can you give me an example?
typescript
add a comment |
Picture this: I've got main.ts
and sw.ts
.
How can I compile main.ts
to js/
folder and sw.ts
to root
directory? Can you give me an example?
typescript
Picture this: I've got main.ts
and sw.ts
.
How can I compile main.ts
to js/
folder and sw.ts
to root
directory? Can you give me an example?
typescript
typescript
asked Nov 25 '18 at 19:38
João LucasJoão Lucas
357
357
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I've found the solution with the help of this page: Projects References.
Step-by-step
First
What worked for me was creating a new tsconfig.json
file for each directory. After that, you should use this, in the main tsconfig.json
:
"references": [
{ "path": "PATH/TO/EACH/OTHER/TSCONFIG.JSON/FILES" }
]
Second
On top of that, you also must add this option to the compilerOptions
of each secondaries tsconfig.json
files:
"composite": true
Third
Also, use "include"
to point to each .ts
files that that particular tsconfig.json
will use:
"include": [
"./homeWork.ts",
"./myGame.ts"
]
or
"include": [
"./*.ts" //Points to every .ts file inside that directory.
]
Fourth
Now, you should be able compile it all, at once, using any of these commands from the same directory as the main tsconfig.json
:
tsc --build
;
tsc -b //Alias for the above command
;
tsc -w -b //Above command, including the option -w for watching changes recursively
.
Considerations
- Note that, using these commands, the compiler will go through each reference that each
tsconfig.json
may have; - This might be a good way to avoid colison between the DOM and WebWorker libraries;
- The references always generate declaration files;
- Compile time gets slower, though I don't know if it is my mistake or a natural thing.
add a comment |
It's impossible within a single compilation.
You will have to run tsc
twice with different tsconfig.json
files or -outDir
options.
Just found the solution to make it compile differenttsconfig.json
files, using just one command (TypeScript 3.0). I will be posting an answer, ASAP.
– João Lucas
Nov 25 '18 at 20:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471155%2fhow-can-i-compile-different-files-to-different-folders-in-typescript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've found the solution with the help of this page: Projects References.
Step-by-step
First
What worked for me was creating a new tsconfig.json
file for each directory. After that, you should use this, in the main tsconfig.json
:
"references": [
{ "path": "PATH/TO/EACH/OTHER/TSCONFIG.JSON/FILES" }
]
Second
On top of that, you also must add this option to the compilerOptions
of each secondaries tsconfig.json
files:
"composite": true
Third
Also, use "include"
to point to each .ts
files that that particular tsconfig.json
will use:
"include": [
"./homeWork.ts",
"./myGame.ts"
]
or
"include": [
"./*.ts" //Points to every .ts file inside that directory.
]
Fourth
Now, you should be able compile it all, at once, using any of these commands from the same directory as the main tsconfig.json
:
tsc --build
;
tsc -b //Alias for the above command
;
tsc -w -b //Above command, including the option -w for watching changes recursively
.
Considerations
- Note that, using these commands, the compiler will go through each reference that each
tsconfig.json
may have; - This might be a good way to avoid colison between the DOM and WebWorker libraries;
- The references always generate declaration files;
- Compile time gets slower, though I don't know if it is my mistake or a natural thing.
add a comment |
I've found the solution with the help of this page: Projects References.
Step-by-step
First
What worked for me was creating a new tsconfig.json
file for each directory. After that, you should use this, in the main tsconfig.json
:
"references": [
{ "path": "PATH/TO/EACH/OTHER/TSCONFIG.JSON/FILES" }
]
Second
On top of that, you also must add this option to the compilerOptions
of each secondaries tsconfig.json
files:
"composite": true
Third
Also, use "include"
to point to each .ts
files that that particular tsconfig.json
will use:
"include": [
"./homeWork.ts",
"./myGame.ts"
]
or
"include": [
"./*.ts" //Points to every .ts file inside that directory.
]
Fourth
Now, you should be able compile it all, at once, using any of these commands from the same directory as the main tsconfig.json
:
tsc --build
;
tsc -b //Alias for the above command
;
tsc -w -b //Above command, including the option -w for watching changes recursively
.
Considerations
- Note that, using these commands, the compiler will go through each reference that each
tsconfig.json
may have; - This might be a good way to avoid colison between the DOM and WebWorker libraries;
- The references always generate declaration files;
- Compile time gets slower, though I don't know if it is my mistake or a natural thing.
add a comment |
I've found the solution with the help of this page: Projects References.
Step-by-step
First
What worked for me was creating a new tsconfig.json
file for each directory. After that, you should use this, in the main tsconfig.json
:
"references": [
{ "path": "PATH/TO/EACH/OTHER/TSCONFIG.JSON/FILES" }
]
Second
On top of that, you also must add this option to the compilerOptions
of each secondaries tsconfig.json
files:
"composite": true
Third
Also, use "include"
to point to each .ts
files that that particular tsconfig.json
will use:
"include": [
"./homeWork.ts",
"./myGame.ts"
]
or
"include": [
"./*.ts" //Points to every .ts file inside that directory.
]
Fourth
Now, you should be able compile it all, at once, using any of these commands from the same directory as the main tsconfig.json
:
tsc --build
;
tsc -b //Alias for the above command
;
tsc -w -b //Above command, including the option -w for watching changes recursively
.
Considerations
- Note that, using these commands, the compiler will go through each reference that each
tsconfig.json
may have; - This might be a good way to avoid colison between the DOM and WebWorker libraries;
- The references always generate declaration files;
- Compile time gets slower, though I don't know if it is my mistake or a natural thing.
I've found the solution with the help of this page: Projects References.
Step-by-step
First
What worked for me was creating a new tsconfig.json
file for each directory. After that, you should use this, in the main tsconfig.json
:
"references": [
{ "path": "PATH/TO/EACH/OTHER/TSCONFIG.JSON/FILES" }
]
Second
On top of that, you also must add this option to the compilerOptions
of each secondaries tsconfig.json
files:
"composite": true
Third
Also, use "include"
to point to each .ts
files that that particular tsconfig.json
will use:
"include": [
"./homeWork.ts",
"./myGame.ts"
]
or
"include": [
"./*.ts" //Points to every .ts file inside that directory.
]
Fourth
Now, you should be able compile it all, at once, using any of these commands from the same directory as the main tsconfig.json
:
tsc --build
;
tsc -b //Alias for the above command
;
tsc -w -b //Above command, including the option -w for watching changes recursively
.
Considerations
- Note that, using these commands, the compiler will go through each reference that each
tsconfig.json
may have; - This might be a good way to avoid colison between the DOM and WebWorker libraries;
- The references always generate declaration files;
- Compile time gets slower, though I don't know if it is my mistake or a natural thing.
answered Nov 25 '18 at 21:29
João LucasJoão Lucas
357
357
add a comment |
add a comment |
It's impossible within a single compilation.
You will have to run tsc
twice with different tsconfig.json
files or -outDir
options.
Just found the solution to make it compile differenttsconfig.json
files, using just one command (TypeScript 3.0). I will be posting an answer, ASAP.
– João Lucas
Nov 25 '18 at 20:50
add a comment |
It's impossible within a single compilation.
You will have to run tsc
twice with different tsconfig.json
files or -outDir
options.
Just found the solution to make it compile differenttsconfig.json
files, using just one command (TypeScript 3.0). I will be posting an answer, ASAP.
– João Lucas
Nov 25 '18 at 20:50
add a comment |
It's impossible within a single compilation.
You will have to run tsc
twice with different tsconfig.json
files or -outDir
options.
It's impossible within a single compilation.
You will have to run tsc
twice with different tsconfig.json
files or -outDir
options.
answered Nov 25 '18 at 20:12
artemartem
14.4k12738
14.4k12738
Just found the solution to make it compile differenttsconfig.json
files, using just one command (TypeScript 3.0). I will be posting an answer, ASAP.
– João Lucas
Nov 25 '18 at 20:50
add a comment |
Just found the solution to make it compile differenttsconfig.json
files, using just one command (TypeScript 3.0). I will be posting an answer, ASAP.
– João Lucas
Nov 25 '18 at 20:50
Just found the solution to make it compile different
tsconfig.json
files, using just one command (TypeScript 3.0). I will be posting an answer, ASAP.– João Lucas
Nov 25 '18 at 20:50
Just found the solution to make it compile different
tsconfig.json
files, using just one command (TypeScript 3.0). I will be posting an answer, ASAP.– João Lucas
Nov 25 '18 at 20:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471155%2fhow-can-i-compile-different-files-to-different-folders-in-typescript%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown