Following angular 2 quick start guide, guys there use typescript compiler and tsconfig.json
file, to work with it. I was looking up ways to use gulp for this and indeed there seem to be ways to achieve this, however I'm a bit confused to correct implementation with angular 2.
essentially gulp-typescript and gulp-tslint seem to be two plugins to achieve this and somehow tsconfig.json
file is also in play here, although I don't grasp why.
Could anyone provide example for implementation that will achieve above? I believe all development .ts files should be within src
folder and javascript needs to be pumped over to build
folder. (assume for now that both folders have setup from angular 2 quick start)
I've setup gulp to work from
gulpfile.js/
folder. In this folder areindex.js
,config.js
andtasks/
folder, and intasks/typescript.js
is task that compiles TypeScript (tasks folder has 15 other tasks). So instead of one hugegulpfile.js
I have manageable chunks that each do just one thing...gulpfile.js/index.js
gulpfile.js/config.js
gulpfile.js/tasks/typescript.js
gulpfile.js/tasks/watch.js
I had an issue with gulp watch: if you're watching files, work on more then one file and save them all it will run a task multiple times, which can be annoying. Check the link for implementation of
queue_tasks()
function...Also note that I'm using Gulp 4:
I've added in
src()
optionsince
to cache files, and pass only changed files down the pipe.I implemented this just 2 days ago and didn't test it with typescript files (works in other places), so if there are issues just remove it...