Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you write Gulp tasks in TypeScript?

How do you write Gulp tasks in TypeScript?

I've seen projects like this where they write gulp tasks in TypeScript so I know it is possible, but I'm having a hard time finding out how they set this up.

like image 570
Michael Warner Avatar asked Sep 19 '16 19:09

Michael Warner


People also ask

How do you write a gulp task?

If you just want a task that runs some function, then just do that: gulp. task('my-custom-task', function () { myCustomFunction('foo', 'bar'); });

What is gulp in TypeScript?

A gulp plugin for handling TypeScript compilation workflow. The plugin exposes TypeScript's compiler options to gulp using TypeScript API. This plugin works best with gulp 4.

How do I run a Gulpfile TS?

You can write a gulpfile using a language that requires transpilation, like TypeScript or Babel, by changing the extension on your gulpfile. js to indicate the language and install the matching transpiler module. For TypeScript, rename to gulpfile. ts and install the ts-node module.

Which is better gulp or grunt?

Gulp vs Grunt: Speed The reason for Gulp's current speed advantage is down to the fact that Gulp uses streams and handles tasks in memory, which means that only one file is written. Furthermore, Gulp can process several tasks at the same time, but Grunt will normally only handle one task at a time.


1 Answers

Ok, after a bit a digging and dicing this project up I found it.

To run gulpfile.ts without compiling the file you can use the 'ts-node' package. This package lets you run TypeScript directly in node and in this case you can use it to run gulp which will compile and run TypeScript on the fly while running your gulp tasks.

I didn't mean to answer my own question but it you find it you might as well share it.

like image 133
Michael Warner Avatar answered Oct 10 '22 22:10

Michael Warner