Search code examples
typescriptgruntjsgrunt-ts

Move compiled Typescript files to parent directory grunt


I'm having some problems trying to output my compiled Typescript files to my parent directory. Let's say I have a structure like this:

app
   routes
   |   src
       | test.ts
       | test2.ts

In this example, I want my compiled test.js and test2.js files to still appear in the routes directory, but not in an src folder. Can anyone give me some guidance? Here's what my Grunt task looks like:

ts: {
  app: {
    files: {
      src: ["**/\*/src/*.ts", "!node_modules/**/*.ts"],
      dest: "."
    },
    options: {
      module: "commonjs",
      noLib: true,
      target: "es6",          
      sourceMap: false
    }
  }
},

Thanks!


Solution

  • I want my compiled test.js and test2.js files to still appear in the routes directory, but not in an src folder.

    Recommend lib folder:

    app
       routes
       |   src
           | test.ts
           | test2.ts
       |   lib
           | test.js
           | test2.js
    

    The option you are looking for is outDir.

    More

    See docs https://github.com/TypeStrong/grunt-ts for more.