node-sass-tilde-importer icon indicating copy to clipboard operation
node-sass-tilde-importer copied to clipboard

1.0.1 breaks importing breakpoint-sass

Open dpalita opened this issue 7 years ago • 13 comments
trafficstars

The latest version breaks importing breakpoint-sass because this lib has a "breakpoint" directory right next to the "_breakpoint.scss" file. This leads to

Error: File to import not found or unreadable: /..../node_modules/breakpoint-sass/stylesheets/breakpoint/index.

I'm fixing the 1.0.0 for now, don't know if it should be fixed by your side (I suppose you should test for the existence of a regular file before checking for the directory) or if the breakpoint-sass layout is considered bad practice... Either way this ..1 release is not backward compatible for everyone.

dpalita avatar Jan 14 '18 13:01 dpalita

Hi @dpalita! Thanks for reporting it, good point the current version will try importing the directory first if that exists and then the file. I checked node-sass behaviour and it does support this scenario, we have to keep it sync, so the fix is needed. In the meantime, you can still use the latest version and import the breakpoint package using ~breakpoint-sass/stylesheets/_breakpoint, that will import the file.

tadam313 avatar Jan 15 '18 09:01 tadam313

Also encountered this issue, switching back to 1.0.0 in the meantime :)

vleput avatar Jan 24 '18 14:01 vleput

Whatt do you mean by "will try importing the directory"? Is your module importing every SASS present in a directory when it finds one?

ericmorand avatar Feb 28 '18 18:02 ericmorand

not every file, but only the "index" one in the particular directory which is being imported. e.g "index.{scss|sass|...}", the extension doesn't matter here. However when we have a file and the directory with the same name (or "compatible name", sass ignores underscore prefix) in the same folder then it favors the directory.

tadam313 avatar Mar 02 '18 22:03 tadam313

Same here with an import of Bootstrap because of the mixins folder :/ Thanks for the tip with the underscore. Any idea if a fix will be released ?

vprothais avatar Jul 31 '18 08:07 vprothais

Run into the same issue with mixins. And I can't just put a .scss extention to it, cause angular won't allow it. Although it compiles with node-sass, if I do.

EduardsE avatar Sep 13 '18 08:09 EduardsE

@tadam313 why would you do that? Importing a directory doesn't make sense.

ericmorand avatar Sep 13 '18 19:09 ericmorand

You can change import to:

@import '~breakpoint-sass/stylesheets/breakpoint.scss';

dawidk92 avatar Feb 12 '19 22:02 dawidk92

This is really strange, the behaviour of a tilde import is different for webpack's style-loader and node-sass-tilde-importer which seems to be used by Angular as well. I would expect to just import @import '~breakpoint-sass', especially having main key specified in the node module. Having this issue with other packages as well. Also, have to structure own packages with index.scss on directories in order to make things work.

rootical avatar May 09 '19 16:05 rootical

plus, "index.scss" isn't really conventional as far as I know.

garrettw avatar May 09 '19 16:05 garrettw

I downgraded to 1.0.0 and can't properly resolve a scoped library either, getting different errors. This is violating semantic versioning: patch version contains breaking changes. Could anyone of maintainers please let us know if this is going to be fixed? Why would we need an index.scss if neither Node or Ruby Sass work this way?

rootical avatar May 10 '19 07:05 rootical

Yes, I'd like to know too why a patch version creates a breaking change and how this was not detected by the test suite. There may be something to improve there.

ericmorand avatar May 10 '19 08:05 ericmorand

If this doesn't work and tries to read directory instead of file: @import "~bootstrap/scss/mixins";

Error: File to import not found or unreadable: /Users/John/Sites/website/node_modules/bootstrap/scss/mixins/index. on line 12 of templates/default/css/content.scss

@import '~bootstrap/scss/mixins';

How do you import the bootstrap mixins? Even with full filename same error as above. @import "~bootstrap/scss/_mixins.scss";

howdu avatar Sep 05 '20 06:09 howdu