Reputation: 1081
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 create
I 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?
Upvotes: 0
Views: 6454
Reputation: 141
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
Upvotes: 1