Skip to content

Conversation

@lencioni
Copy link
Contributor

@lencioni lencioni commented Dec 1, 2015

According to the node-sass documentation:

If an importer does not want to handle a particular path, it should
return sass.NULL.

https://github.com/sass/node-sass#importer--v200---experimental

This will allow other importers to properly handle the import. Some more
discussion on this can be found at:

webpack/sass-loader#170 (comment)

Since the documentation says that this is true as of 3.0.0, that's where
I set the dependency version.

According to the node-sass documentation:

> If an importer does not want to handle a particular path, it should
> return `sass.NULL`.

https://github.com/sass/node-sass#importer--v200---experimental

This will allow other importers to properly handle the import. Some more
discussion on this can be found at:

  webpack/sass-loader#170 (comment)

Since the documentation says that this is true as of 3.0.0, that's where
I set the dependency version.
This reduces the nesting in most of this function by one level,
improving the readability slightly.
@pmowrer
Copy link
Owner

pmowrer commented Dec 1, 2015

Nice work!

pmowrer added a commit that referenced this pull request Dec 1, 2015
Return `sass.NULL` when not handling the file
@pmowrer pmowrer merged commit dce4b7d into pmowrer:master Dec 1, 2015
@lencioni
Copy link
Contributor Author

lencioni commented Dec 1, 2015

Thanks! Unfortunately, this only seems to resolve half of the problem I was running into. Do you know of a way for me to use this importer with sass-loader so that things like @import '~my_config.json' will work? It needs to use webpack to resolve what the ~ means, but then it needs to use this importer to resolve the JSON itself.

@lencioni
Copy link
Contributor Author

lencioni commented Dec 1, 2015

Maybe I need to better utilize node-sass includePaths option instead of relying on webpack to resolve everything.

@lencioni
Copy link
Contributor Author

lencioni commented Dec 1, 2015

@pmowrer Any chance you could cut a new release? :)

@kenjiqq
Copy link

kenjiqq commented Dec 3, 2015

This change seems to break some imports when node-sass in run from another package, for instance grunt-sass.
Because two packages that use node-sass each have they own node-sass in their node_modules the sass.NULL value you return here will not have the same object reference as the node-sass module that called the importer.
So the following check in node-sass fails because it't not the same NULL object and node-sass interprets that as if the importer is handling all imports.

var result = importer.call(options.context, file, prev, done);

if (result) {
    done(result === module.exports.NULL ? null : result);
}

@trotzig
Copy link

trotzig commented Dec 9, 2015

@kenborge do you think what you mention above could be the cause of #15 as well?

@pmowrer
Copy link
Owner

pmowrer commented Dec 9, 2015

Sounds like we need some guidance from node-sass. Thanks for creating the following ticket @kenborge. Linking it here so we can keep tabs on the discussion:
sass/node-sass#1291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants