gulp-community / gulp-concat

Streaming concat middleware for gulp
MIT License
792 stars 127 forks source link

Gulp Concat doesn't include parent folder from blob in path #136

Closed josephkerkhof closed 7 years ago

josephkerkhof commented 7 years ago

Hello,

I am having a bit of a problem getting my concatenated CSS to be moved into the correct directory. Normally, Gulp will move files from the blobbed (**) source directory to a directory of the same name in the destination directory. For some reason, when I include the concat function, it removes all traces of the blobbed parent directory, and places it directly inside the destination folder.

Is there a way to get the blobbed parent directory to move over with the concatenation? I have included a screenshot and working gulp task as an example below my 'theme-style' task.

gulp.task('theme-style', function () {
  // Function to check if file contains WordPress theme metadata
  var notThemeMetadata = function(file){
    var filenameSplit = String(file["history"]).split('/');
    var filename = filenameSplit[filenameSplit.length-1];
    if(filename != 'theme-metadata.css'){
      return true;
    }
    return false;
  }

  return gulp.src(['src/themes/**/theme-metadata.css', 'src/themes/**/style/*.scss'])
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['last 2 versions']
    }))
    .pipe(gulpif(notThemeMetadata, cssnano()))
    .pipe(concat('style.css')) // This is the troublesome bit
    .pipe(gulp.dest('builds/themes/'));
});

// Example of a task putting the files where it should
gulp.task('theme-js', function(){
  return gulp.src('src/themes/**/js/**/*.js')
      .pipe(babel({
        presets: ['es2015']
      }))
      .pipe(uglify())
      .pipe(gulp.dest('builds/themes/'));
});

screen shot 2017-02-23 at 1 18 08 pm

yocontra commented 7 years ago

You have files coming from multiple theme directories being concatenated into one file. What do you expect the behavior to be? Can you make a more concise example?

josephkerkhof commented 7 years ago

I expect the behavior to be putting style.css into whatever the blobbed directory is. I want it set up so that any directory in my themes source folder gets put into the same named build folder.

In this case, I expect style.css into uw-oshkosh-divi.

yocontra commented 7 years ago

@musicaljoeker You're combining files from multiple blobbed directories into one file, I don't think your code is working the way you think it is.

You want to combine each theme into one file then put that file in the root of that theme's folder? You'll have to write code that does that. All this plugin does is combine given files into one file.

Right now your code is combining every css file for every theme into one css file, not every theme into a file per theme.