Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add an import resolver for tilde (~) node_modules imports #277

Closed
ghost opened this issue Nov 6, 2020 · 6 comments · Fixed by #278
Closed

Please add an import resolver for tilde (~) node_modules imports #277

ghost opened this issue Nov 6, 2020 · 6 comments · Fixed by #278
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ghost
Copy link

ghost commented Nov 6, 2020

I know that svelte-preprocess adds node_modules to the scss/sass includePaths automatically, but this will only resolve import/use statements in the form of module/..., not ~module/..., which has become a standard for importing modules in scss. Even VSCode will highlight and link paths relative to node_modules when prefixing them with a tilde (a path without one will however not be resolved correctly).
Would it be possible to treat tilde-prefixed paths as relative to node_modules as well, like a lot of webpack plugins have been doing already?

@kaisermann kaisermann self-assigned this Nov 7, 2020
@kaisermann kaisermann added the enhancement New feature or request label Nov 7, 2020
@kaisermann
Copy link
Member

kaisermann commented Nov 7, 2020

Hey @GitGangGuy 👋

I think it's possible to add a custom importer that just removes the initial ~ character and leave the rest to the includePaths resolution. Will try to tackle it today.

@ghost
Copy link
Author

ghost commented Nov 7, 2020

@kaisermann Thank you for addressing this!

@kaisermann kaisermann added the help wanted Extra attention is needed label Nov 8, 2020
@kaisermann
Copy link
Member

kaisermann commented Nov 8, 2020

It seems sass doesn't pass an importer returned value through the includePaths and it expects an absolute path. This complicates it a little bit more. For now, you could try using node-sass-tilde-importer and see if it works for you!

Edit:
I managed to get it working 🎉 Just waiting for the CI and will release it.

@ghost
Copy link
Author

ghost commented Nov 8, 2020

@kaisermann I use dart sass, so node-sass extensions aren't an option. Thanks for getting it working anyway!

@kaisermann
Copy link
Member

@GitGangGuy AFIK both sass and node-sass importers have the same API. It's just a function.

@ghost
Copy link
Author

ghost commented Nov 27, 2020

The PR was merged, why is this issue still open? ^^
I'll go ahead and close it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant