G
G
gleendo2016-07-01 00:03:21
css
gleendo, 2016-07-01 00:03:21

How to monitor imported files in gulp and recompile the main ones?

I understand with gulp, you just need to follow and compile the stylus and jade files.
I googled it, I got this gulp file and this is the structure: Link to screenshot
Now it works fine only if changes are made to the main files.
But they also have imports. And I thought that when you change the file that is imported, there will be changes in the main file and it will be recompiled, but this is not the case as it turned out.
In general, how to make it so that when any file is changed, recompilation occurs.
For example, I changed the value of a variable in the vars.styl file and the changes were reflected on the page. So that gulp knows that I changed the import file and recompiled the main one, in which all the imports.
Perhaps you understand) Thank you in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Yarkov, 2016-07-01
@evgeniy8705

gulp.src([
            "path/to/stylus/**/*.styl",
            "!path/to/stylus/**/_*.styl"
        ])

K
Konstantin Velichko, 2016-07-01
@Zoxon

Look at my template there, this is also implemented for jade https://github.com/zoxon/gulp-front

R
ROBsoer, 2016-07-04
@ROBsoer

You need the watcher to keep track of all files of a certain type, and only the main ones to the input of the handlers.
This is how your watch-task will look like:

gulp.task("watch", function () {
  gulp.watch("application/jade/**/*.jade", ["jade"]);
  gulp.watch("application/stylus/**/*.styl", ["stylus"]);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question