S
S
Sergey2021-12-18 01:36:44
gulp.js
Sergey, 2021-12-18 01:36:44

How to set cache for files with mixins only?

I'm trying to reduce the time to compile the project. The folder structure is like this:

/pug
  /common
      layout.pug
  /components
      blocks.pug
      components.pug
      elements.pug
  index.pug
  ...


layout.pug includes components.pug , which in turn includes blocks.pug and elements.pug with mixins. Over time, there were too many pages, blocks and elements, and it began to take about a minute to compile. I connected gulp-cached and divided the compilation of pug into two tasks: one for pages, the other for components.
gulp.watch(['src/pug/*.pug'], compilePagesPug);
gulp.watch(['src/pug/common/*.pug', 'src/pug/components/*.pug'], compileAllPug);


Now compileAllPug is the same as compilePagesPug , but without the cache.

With the pages everything is clear and understandable and works perfectly. But what about the components? They are not compiled into html files and, if I understand correctly, gulp sees that the file has been changed, runs compileAllPug , and inside the task, gulp-cached thinks that nothing has changed (which, in principle, is logical for it, probably) and further actions are accordingly not work.

Or maybe I'm too clever with the structure and everything is much simpler?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question