I'm kinda new to front end development, being a long time backend C# and Java developer, and I'm trying to come to grips with how to build front end applications. I would like to build an application using typescript and use gulp for my build pipeline to transpile, bundle and minify my code to a single JavaScript file.
For this purpose, I have been looking at the node module tsproject which, as far as I can understand, is supposed to do exactly what I want. Except, I can't get it to do what I want :-(.
This is the relevant parts my gulpfile.js:
var gulp = require('gulp');
var clean = require('gulp-clean');
var tsproject = require('tsproject');
gulp.task('default', [ 'min-js' ]);
gulp.task('clean', function () {
return gulp
.src('./dist/', { read: false })
.pipe(clean());
});
gulp.task('min-js', [ 'clean' ], function () {
return tsproject
.src('./tsconfig.json')
.pipe(gulp.dest('./dist/js'))
});
And my tsconfig.json:
{
"compilerOptions": {
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"jsx": "react",
"outDir": "./"
},
"files": [
"./src/**/*.tsx",
"./src/**/*.ts"
],
"bundles": {
"myApp": {
"files": [
"./src/App.tsx"
],
"config": {
"minify": true,
"sourcemap": true
}
}
}
}
I had expected this to output a single js-file containing transpiled, bundled and minified JavaScript code but what I get is a bundled (not transpiled nor minified) Typescript file (./dist/js/myApp.min.ts).
Am I doing something wrong or have I completely misunderstood the purpose and intent of tsproject?