tschaub / gulp-newer

Pass through newer source files only
https://npmjs.org/package/gulp-newer
226 stars 24 forks source link

Feature: dependency map #49

Open bustbr opened 7 years ago

bustbr commented 7 years ago

This feature allows to specify extra dependencies of files, much like the extra option, but instead of a single array (or string or glob), which is mostly useful when generating only a single output file, the map feature allows a gulp task to rebuild only the necessary files even in a many:many situation.

const depMap = {
  "/some/place/a.scss": [
    "/some/place/else/b.scss",
    "/some/place/else/c.scss"
  ],
  "/some/place/d.scss": [
    "/some/place/else/b.scss"
  ],
  "/some/place/e.scss": [
    "/some/place/a.scss"
  ]
};
gulp.task('build:styles', function() {
  return gulp.src('/some/place/*.scss')
      .pipe(newer({
        dest: "dist",
        dependencyMap: depMap
      }))
      .pipe(sass())
      .pipe(gulp.dest('dist'));
});
bustbr commented 7 years ago

Hi,

I'd like to find out what's stopping this pull request from being merged into upstream. I understand that another approach, instead of supplying a static map, would be to allow "extras" to be a function, like requested in this issue https://github.com/tschaub/gulp-newer/issues/48

I need this feature for a project and I'd love to have it be part of the main repository, not only in a fork of mine I'd have to keep up to date if any features are added to gulp-newer.

Thanks in advance.

macfiss commented 7 years ago

@bustbr, Hello. Not working :(

let src = [
   'src/core/styles/**/[^_]*.styl',
   'src/vendor/styles/**/[^_]*.styl'
];
return gulp.src(src, {cwd: config.root}) //src/core/styles/styles.styl
               .pipe(newer({
                   dest: config.dest.css,
                   ext : '.css',
                   dependencyMap: {
                        'src/core/styles/styles.styl': [
                            'src/blocks/header/default/styles/style.styl',
                           //or 'src/blocks/*/*/styles/style.styl',
                        ] 
                   }
                   //extra: '!src/core/styles/styles.styl'
               }))
             //....