How can I compile different files to different folders, in TypeScript?












0















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?










share|improve this question



























    0















    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?










    share|improve this question

























      0












      0








      0








      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?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 25 '18 at 19:38









      João LucasJoão Lucas

      357




      357
























          2 Answers
          2






          active

          oldest

          votes


















          1














          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.






          share|improve this answer































            0














            It's impossible within a single compilation.



            You will have to run tsc twice with different tsconfig.json files or -outDir options.






            share|improve this answer
























            • 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











            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            1














            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.






            share|improve this answer




























              1














              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.






              share|improve this answer


























                1












                1








                1







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 25 '18 at 21:29









                João LucasJoão Lucas

                357




                357

























                    0














                    It's impossible within a single compilation.



                    You will have to run tsc twice with different tsconfig.json files or -outDir options.






                    share|improve this answer
























                    • 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
















                    0














                    It's impossible within a single compilation.



                    You will have to run tsc twice with different tsconfig.json files or -outDir options.






                    share|improve this answer
























                    • 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














                    0












                    0








                    0







                    It's impossible within a single compilation.



                    You will have to run tsc twice with different tsconfig.json files or -outDir options.






                    share|improve this answer













                    It's impossible within a single compilation.



                    You will have to run tsc twice with different tsconfig.json files or -outDir options.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 25 '18 at 20:12









                    artemartem

                    14.4k12738




                    14.4k12738













                    • 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

















                    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


















                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                    Calculate evaluation metrics using cross_val_predict sklearn

                    Insert data from modal to MySQL (multiple modal on website)