JoeNyland
JoeNyland

Reputation: 293

Ignoring SCSS/SASS partials in Gulp task

I've got the following structure:

├── assets
│   └── css
│       └── output.css
├── gulpfile.js
├── index.html
├── package.json
└── scss
    ├── some-other.css
    ├── _base.scss
    ├── _config.scss
    ├── _helpers.scss
    ├── _home.scss
    └── main.scss

I'm using Gulp to compile the CSS and SCSS files in scss/ into one file in assets/css/. This is the relevant task from my gulpfile.js:

gulp.task('build-css', function() {
  return gulp.src(['scss/**/*.scss','scss/**/*.css'])
    .pipe(concat('output.css'))
    .pipe(sass())
    .pipe(gulp.dest('assets/css'));
});

The problem is that my SCSS/SASS partials (those files starting with an underscore in scss/ get fed through the the task and ultimately fail.

I'd like to ignore the files anywhere in scss/ that start with an underscore and end with .scss.

I've taken a look at the following but I wasn't able to get it to work:

Upvotes: 1

Views: 1409

Answers (1)

JoeNyland
JoeNyland

Reputation: 293

It seems that I was mislead and using the suggestions in the linked questions I was actually able to get this working with the following:

gulp.task('build-css', function() {
  return gulp.src('scss/**/[^_]*.?(s)css')
    .pipe(concat('output.css'))
    .pipe(sass())
    .pipe(gulp.dest('assets/css'));
});

Sorry for the noise - I should have been more thorough in my testing before asking the question. Hope this helps someone, though.

Upvotes: 5

Related Questions