mariocasciaro / gulp-concat-css

Concatenates css files, bubbling up import statements (as per the standard), and optionally rebasing urls and inlining local import statements.
MIT License
78 stars 19 forks source link

Improve error reporting for CSS syntax errors #7

Open mariocasciaro opened 10 years ago

vitorbaptista commented 8 years ago

Might be related to this issue. If a CSS has an invalid import, like:

/* missing semicolon */
@import "foo"
@import "bar"

gulp-concat-css will throw a quite cryptic error. The issue is in:

// https://github.com/mariocasciaro/gulp-concat-css/blob/master/index.js#L61-L62
var importData = parseImport('@import ' + rule.import + ';');
var importPath = importData && importData[0].path;

parseImport returns an empty array when it couldn't find any imports, so although importData is truthy, import[0] is undefined, and the code blows up. This seems like a good place to add a check if importData[0] exists and, if not, throw a friendlier error.