vlio20
vlio20

Reputation: 9295

issue with typescript output scaffolding (keep structure)

I am using tsconfig.json to compile my ts files. all my files ts located under src folder and I would like my output to be under dist folder. Here is my current output:
enter image description here

As you can see the structure doesn't kept. I would like to find test.js to be under: 'dist/controller/test.js'.
Here is my tsconfig.json file:

{
  "compilerOptions": {
    "target": "es6",
    "sourceMap": true,
    "outDir": "dist/"
  },
  "exclude": [
    "node_modules"
  ]
}

And here is my gulp task:

var tsProject = ts.createProject('tsconfig.json');

gulp.task('scripts', () => {
  var tsResult = tsProject.src()
    .pipe(ts(tsProject));

  return tsResult.js.pipe(gulp.dest('dist'));
});

Upvotes: 2

Views: 106

Answers (1)

vlio20
vlio20

Reputation: 9295

I have to add rootDir to achieve it, take a look at my fixed tsconfig file:

{
  "compilerOptions": {
    "target": "es6",
    "sourceMap": true,
    "outDir": "dist/",
    "rootDir": "./src"
  },
  "exclude": [
    "node_modules"
  ]
}

Upvotes: 1

Related Questions