Feiyang1 / awesome-typed-sass-modules

9 stars 7 forks source link

Not working with @import inside sass file, and no aliases support, -w not work #15

Open vitaliy-du opened 5 years ago

vitaliy-du commented 5 years ago

File to import not found or unreadable: ~bourbon/core/bourbon.

/sources is alias Error: File to import not found or unreadable: /sources/sass/global.

Feiyang1 commented 5 years ago

Can you please provide some more detail? What command were you running?

vitaliy-du commented 5 years ago

atsm sources -p */.sass -o types In global.sass file i have @import "~bourbon/core/bourbon", its without alias, import bourbon.scss from node_modules. And then i see a message File to import not found or unreadable: ~bourbon/core/bourbon Also i use aliases for import @import "/sources/core/bourbon" where /sources is alias for specify absolute path for import.

hally9k commented 5 years ago

Yeah, I'm getting an error when using this on scss files with @import statements with ~ prefix. File to import not found or unreadable

Feiyang1 commented 5 years ago

It appears ~ prefix is not part of the sass spec, but something sass-loader added to work with webpack. This tool is only intended to support standard sass features, so I don't think ~ prefix is going to be supported.

vitaliy-du commented 5 years ago

https://github.com/webpack-contrib/sass-loader#imports, in that case your tool is not fully support sass, and have seriously restriction.

Feiyang1 commented 5 years ago

I don't think it's fair to say the tool doesn't fully support sass since ~ is not part of the sass standard. It's a webpack specific thing and depends on webpack resolving engine AFAIK.

This tool delegated all sass related functionalities (parsing, import resolution) to node-sass. and I think they fully support sass.

That being said, I found an API in node-sass that allows you to plug in your own import resolution logic. And there is already a npm module that provides this logic (https://www.npmjs.com/package/node-sass-tilde-importer). You can take a look at it and see if it works for you. PR is welcomed. Otherwise I will take a look in a few days when I get time.

Feiyang1 commented 5 years ago

Released 1.2.0 with ~ import support. Can you please try the new version?

vitaliy-du commented 5 years ago

Path with .extension @ import "~bourbon/core/bourbon.scss" is worked, without extension @ import "~bourbon/core/bourbon" Error: File to import not found or unreadable: .../node_modules/bourbon/core/bourbon/index. The @ import from root or relative not worked too.