0

I'm banging my head with what should be a simple fix to a gulpfile that would allow it to build scss files.

I have the following structure in my angular2 project: |-rootDir |-- app |--- <bunch of stuff in the app dir> |-- resources |--- scss |---- <scss files>

However, whenever I run gulp createI get an error stating Error: Invalid glob argument: undefined

What am I doing wrong here???

This is my gulpfile:

var gulp = require('gulp'), sass = require('gulp-sass'), minifycss = require('gulp-minify-css'), autoprefixer = require('gulp-autoprefixer'), concat = require('gulp-concat'), debug = require('gulp-debug'), del = require('del'), insert = require('gulp-insert'), fs = require("fs"); /* Tasks Functions */ sass = function(files, dest) { pipe_files = gulp.src(files); return pipe_files .pipe(debug()) .pipe(sass().on('error', sass.logError)) .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4')) .pipe(minifycss()) .pipe(gulp.dest(dest)); } /* CSS Tasks */ gulp.task( 'styles', function() { sass( ['./resources/scss/*.scss'], './resources/css_gulp/') }); gulp.task('clean', function(cb) { del(['./resources/css_gulp/*.*'], cb) }); gulp.task( 'create', function() { gulp.start('styles'); }); gulp.task('default', ['clean'], function() { gulp.start('create'); }); 

So, where am I going wrong on the paths?

* EDIT * I've added gulp-debug and this is the output: [20:03:40] Finished 'create' after 17 ms [20:03:40] gulp-debug: resources/scss/main.scss [20:03:40] gulp-debug: resources/scss/prime-overrides.scss [20:03:40] gulp-debug: 2 items

Everything seems correct here. So why the error?

5
  • I don't think that the sass function take the array of paths. AFAIK you shoud pass an object with a property includePaths that is the array of paths. Commented Aug 16, 2016 at 19:22
  • Hmm I'll look into that but I think that is a recent change maybe? On my other project where I use gulp I have it set up exactly like this and it is working Commented Aug 16, 2016 at 19:38
  • 3
    You're redefining sass. Commented Aug 16, 2016 at 19:46
  • Jesus it's always the stupidest things that get me making this kind of questions.. sigh Please promote that to an answer and I'll mark it as correct. That was indeed the issue :palmface: Commented Aug 16, 2016 at 19:49
  • @SvenSchoenung got it! Commented Aug 16, 2016 at 19:49

1 Answer 1

1

As pointed out by Sven in comment. The issue seems to be caused due to defining the task function "sass".

Changing the function name would solve it.

I have seen similar errors with src() function before especially when mainBowerFiles dependency is loaded but not called properly in gulp.src()

It would be easier to identify such issues if as a principle we write the entire callbacks separately and also ensuring that String or Array of glob getting passed.

gulp.task('myTask', myTaskCallback); // myTaskCallback implementation function myTaskCallback() { return gulp.src() // ensure Glob or array of globs to read. .pipe()...... } 

More can be found in the gulp documentation. https://github.com/gulpjs/gulp/blob/v3.9.1/docs/API.md

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.