I am using VS Code for making an HTML5 game with TypeScript (JS). The project is getting a little bigger and I want to store the output in a different directory. The problem is that whenever I compile everything, it mirrors the original directory hierarchy. So for example:
-dir1
--dir2
--dir3
---dir4
outputs:
-dir1
--dir2
--dir3
---dir4
(the same)
and I want:
-dir1
*.js
I've tried Grunt/Gulp/VSCode's own TaskRunner but nothing works and "keepDirectoryHierarchy" seems depricated..
Put next configuration in it
{
"version": "1.6.0-beta",
"compilerOptions": {
"target": "es5",
"declaration": true,
"noImplicitAny": false,
"removeComments": true,
"noLib": false,
"emitDecoratorMetadata": true,
"sourceMap": true,
"listFiles": true,
"outDir": "",
"out": "./Compiled/mycompiled.js", // here specify your output file( it would be contain all your compiled ts file in one)
"experimentalDecorators": true
},
"files": [ // file list (optional)
"somefile.ts"
]
}
Configure VS Code task runner
Current example show how you should modify your gulpfile.js to compile your project using gulp-typescript
gulp.task('build', function () {
var tsResult = gulp.src('src/**/*.ts') // here specify your file location or folders
.pipe(ts({ // gulp-typescript configuration
noImplicitAny: true,
out: 'output.js'// here specify your output file( it would be contain all your compiled ts file in one)
}));
return
tsResult.js
.pipe(gulp.dest('./')); // here you can specify your output directory too
});
For your case you can choose both solutions. Pay attention for code comments and specify out directories and name of compiled js file as you wish.
Good Luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With