Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
josephkerkhof opened this issue Feb 23, 2017 · 3 comments
Closed

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

josephkerkhof opened this issue Feb 23, 2017 · 3 comments

Comments

@josephkerkhof
Copy link

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
Copy link
Member

yocontra commented Feb 23, 2017

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
Copy link
Author

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
Copy link
Member

yocontra commented Feb 23, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants