-
Notifications
You must be signed in to change notification settings - Fork 1.3k
What should an importer function do if the requested file cannot be found? #632
Comments
|
That would appear to libsass as if the file does exist and it's just empty.
|
@callumlocke sorry thought you were asking to make it not error out. |
Sorry I am lost, what exactly is the requirement here? Currently libsass produces the error if you only return the non-existing file from custom importer: Synchronous: require('node-sass').renderSync({
data: '@import "foo.scss"',
importer: function(u,p){
return {file:"devNull"};
}
});
// throws the following on stderr
{
"status": 1,
"file": "stdin",
"line": 1,
"column": 9,
"message": "file to import not found or unreadable: devNull\nCurrent dir: "
} Asynchronous: require('node-sass').render({
data: '@import "foo.scss"',
importer: function(u, p, done) {
done({file:"devNull"}) // you can also return from asynchronous ignoring done
},
error: function(e){ console.error(e) }
});
// prints:
{ file: 'devNull' } // this output on console is a workaround for v8/libuv issue, just ignore it.
{ status: 1,
file: 'stdin',
line: 1,
column: 9,
message: 'file to import not found or unreadable: devNull\nCurrent dir: ',
code: 1 } |
I don't know if this belongs here (I'll also create another issue and post the # here), but when I try to compile using @import url(http://some.external/file) and I don't have internet access, I get this error: Broken @import declaration of "https://fonts.googleapis.com/css?family=Mr+Dafoe" - timeout |
@joshbroton, there are two kinds of imports: CSS3 and Sass. @callumlocke, should we close this issue? |
I still have a problem, but I think it actually stems from the way libsass has implemented custom importers, and I've started an issue there instead (sass/libsass#862)... if that one ever gets fixed then I might open a clearer issue here :) |
Say my custom importer function is called, asking for something called
'foo'
, and I determine that the file does not exist (i.e. the@import 'foo'
is an error)...I should be able to call
done
in some special way to explicitly indicate that the requested file does not exist, causing libsass to call myerror
callback with an appropriate error object (including the line number of the bad@import
).Something like
done(false)
ordone({file: false})
would be good.The text was updated successfully, but these errors were encountered: