D
D
denis26012018-08-21 23:23:20
gulp.js
denis2601, 2018-08-21 23:23:20

How to check included files for changes?

Such is the problem, there is a components folder in which folders with pages are located 5b7c82e8193b9597499957.png, inside which there is the main index.html file and the templates folder in which the modules of this page are stored, 5b7c832b06eed675399179.png
these modules can be connected not only in this component, but also in other components, for example which one some module from alerts -> templates is connected to index -> index.html, etc. via @@include("../alerts/template/model.html")
The problem is that with a large number of such components, their assembly starts to slow down, not the modified file is rebuilt, but all at once, but you need, for example, what if I changed any module in the templates pack, and only those files in which it is connected were rebuilt, and not only, only the component file that was directly changed was also rebuilt.
When building, the task bypasses all component folders (components -> "alerts,index, ... "), finds all index.html, collects them and renames them to the name of the folder in which it is located and sends it to the dist folder 5b7c8357768a0729528539.png
. I have the gulp-changed plugin does not work under any conditions, even if the file was changed directly, not included.

function onError(e) {
  console.log(e.toString());
  this.emit('end');
  }

  /* Secondary functions */
  var getFolders = function (dir) {
  return plugins.fs.readdirSync(dir)
  .filter(function (file) {
  return plugins.fs.statSync(plugins.path.join(dir, file)).isDirectory();
  });
  };
  /* End Secondary functions */

  /* Paths */
  var src = {
  components: 'src/components'
  },
  dist = {
  components: 'dist'
  };
  /* End Paths */

  gulp.task('html', function () {
  var components = getFolders(src.components).map(function (folder) {

  return gulp.src(plugins.path.join(src.components, folder, '/index.html'))
  .pipe(plugins.changed(dist.components, {hasChanged: plugins.changed.compareSha1Digest}))
  .pipe(plugins.plumber({errorHandler: onError}))
  .pipe(plugins.fileInclude())
  .pipe(plugins.concat(folder + '.html'))
  .pipe(gulp.dest(dist.components));
  });

  return plugins.merge(components);
  });

If anyone faced such a problem, share your experience, how did you solve it?
Thank you!

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