Automatically configure gulp using tsconfig file and provides build in actions such as clean, build...
MIT License
Yet another typescript plugin. This one remove the boilerplate of using gulp-typeScript. For example, you can generate sourceMap without the burden of configuration gulp-sourcemaps plugin: you provide this plugin with a valid tsconfig.json, from your build task call useTsConfig build() and... you've done.
const gulp = require('gulp');
const useTsConfig = require('gulp-use-tsconfig');
const tsConfig = './tsconfig.json';
gulp.task('lint', function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.lint());
});
gulp.task('pre-build', function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.clean()); // Remoce all .js; .map and .d.ts files
});
gulp.task('build', gulp.series(['lint', 'pre-build'], function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.build());// generates .js and optionaly .map anod/or .d.ts files
}));
gulp.task('watch', gulp.series(['build'], function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.watch());
}));
gulp.task('default', ['build']);
npm install --save gulp-use-tsconfig
"Pipes" your tsconfig to the plugin and call build method:
const gulp = require('gulp');
const useTsConfig = require('gulp-use-tsconfig');
const tsConfig = './tsconfig.json';
gulp.task('build', gulp.series(['pre-build'], function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.build());// generates .js and optionaly .map anod/or .d.ts files
}));
gulp-use-tsconfig analyses your tsconfig.json and does the job.
"Pipes" your tsconfig to the plugin and call clean method:
const gulp = require('gulp');
const useTsConfig = require('gulp-use-tsconfig');
const tsConfig = './tsconfig.json';
gulp.task('pre-build', function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.clean()); // Remoce all .js; .map and .d.ts files
});
"Pipes" your tsconfig to the plugin and call watch method:
const gulp = require('gulp');
const useTsConfig = require('gulp-use-tsconfig');
const tsConfig = './tsconfig.json';
gulp.task('watch', function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.watch());
});
"Pipes" your tsconfig to the plugin and call lint method:
gulp.task('lint', function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.lint());
});
Lint accepts an object configuration, with two properties:
{
tsLintOptions : configuration of gulp-tsLint
reporterOptions: configuration of gulp-tsLint reporter
}
Click here for more information about tslint
Another example using some configuration options:
gulp.task('lint', function() {
return gulp.src(tsConfig)
.pipe(useTsConfig.lint(
{
tsLintOptions: {
formatter: 'prose',
},
reporterOptions: {
summarizeFailureOutput: false,
emitError: false,
},
}
));
});
Folowing optons of tsconfig.json is directly managed by gulp-useTsConfig:
If the "files" and "include" are both left unspecified, the compiled files are **/*.ts, **/*.d.ts and **/*.tsx.
Requires Node 6.0.0 or upper. Require typescript 2.x or upper.
MIT