gulpclass icon indicating copy to clipboard operation
gulpclass copied to clipboard

Loading tasks from multiple files

Open iamrakesh opened this issue 7 years ago • 2 comments

Hi, FAQ section of readme, explains about what needs to be in gulpfile.js, but I couldn't make it work, I've trouble with how to add tasks in other .ts files.

The way I tried is to have a class 'MyTasks' with tasks in one.ts, in gulpfile.ts have Gulpfile class extend MyTasks. But this doesn't seems to work.

Could please provide a full example on how to do this ?

Thanks, Rakesh.A

iamrakesh avatar Sep 25 '16 13:09 iamrakesh

everything is already described in faq section, try more and you'll success. Alternatively you can try ts-node to run gulp tasks without this compilation hack in .js

pleerock avatar Sep 25 '16 15:09 pleerock

Hi @iamrakesh,

I also had issues loading my gulpfiles from different files. I had some settings in my tscofnig.json and did not want to load this when evaling the scripts, as I did not want to have more dependencies. I think the problem was that my tsconfig did resolve the require differently.

I simply fixed this by creating a static init method on the loaded gulpclass:

gulpfile.ts:

import { Deploy } from "./deployment";
...
Deploy.init();

deployment.ts:

@Gulpclass()
export class Deploy {
    @SequenceTask()
    deploy() { ... }
    ...
    static init() {
        console.log("Initialized Deyployment");
    }
}

This init call forces to load the module and, thus, create the missing tasks on the Deploy class.

@pleerock: Maybe you could add this als alternative route.

apazureck avatar Feb 14 '18 08:02 apazureck