D
D
Dima2016-01-28 02:27:35
JavaScript
Dima, 2016-01-28 02:27:35

How to intercept file being processed in gulp?

Actually, subject. The meaning is this: the galpa task is running, how can I intercept the file or get its url (I want to write it down in locals jade in order to pass it to jade templates)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
Homsa Toft, 2016-01-31
@kostein

If you need to throw data into the template, then gulp-data . It would be more interesting for me to get a tree of all extends and include files, for example, to take data from _nav.jade.json, which, as it were, does not participate in compilation.

var getJadeDependencies = function (file) {
    return require(`jade`).compileFile(file).dependencies;
};

But there is no time yet, and there is not enough knowledge in JS.

A
Askar Mukhametshin, 2016-01-28
@Maskazan

If I understand correctly: hang after gulp.src gulp-filenames , then at the end of the stream, run the jade bundle with the entire list of files from the stream.
Offtopic:
Personally, I use this pattern: there is a certain json file into which I throw everything that I may need at the same time in js, jade or stylus, and then I pull it apart through locals (jade gult), require (js babel) and json ( style).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question