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

Add ~ (tilde) as shortcut for {}/node_modules? #246

Closed
ghybs opened this issue Apr 14, 2017 · 11 comments
Closed

Add ~ (tilde) as shortcut for {}/node_modules? #246

ghybs opened this issue Apr 14, 2017 · 11 comments

Comments

@ghybs
Copy link
Contributor

ghybs commented Apr 14, 2017

Webpack Sass loader provides the ~ (tilde) prefix as a way to tell the compiler that it should resolve the path using a configured array of module directories (typically <projectRoot>/node_modules, but can be anything specific to the project).

Some IDE's (e.g. WebStorm) provide path resolution analysis and highlighting based on the assumption that the ~ means <projectRoot>/node_modules.

Some libs provide similar functional extension, e.g. https://github.com/matthewdavidson/node-sass-tilde-importer

We could do the same in this package by checking if ~ is the first character in the path, and replace it with {}/node_modules, or anything configured in scss-config.json for example.

Note: the ~ syntax (or some kind of special syntax) is needed by contrast with ES6 import because in Sass, "./style" and "style" are the same.

@ghybs ghybs changed the title Add ~ (tilde) as shortcut for {}/node_modules? Add ~ (tilde) as shortcut for {}/node_modules? Apr 14, 2017
@sebakerckhof
Copy link
Collaborator

sebakerckhof commented Apr 14, 2017

Do you know if that is sass specific, or if it is also used in the same way for less and other alternatives?
If so, we should maybe coordinate with authors of those Meteor packages (e.g. MDG) so we get similar behavior across packages.

Edit: see #246

@ghybs
Copy link
Contributor Author

ghybs commented Apr 14, 2017

Thank you for quick feedback and action!

I like the idea of trying to coordinate the behaviour, hence the syntax!

I am not sure the exact extent of that ~ syntax, but it seems to be pretty common practice for webpack now:

Besides the webpack Sass loader previously mentioned, as well as the node Sass tilde importer (not webpack).

@sebakerckhof
Copy link
Collaborator

@ghybs I kinda lost track of this. But if you're willing to work on this, I'd be happy to merge a PR.

@ghybs
Copy link
Contributor Author

ghybs commented Jun 27, 2017

Hi @sebakerckhof,

Thank you for the heads up!

I must admit I forgot about it as well, thinking we were waiting for some input in meteor/meteor#8601.

I will see when I have time to send you a PR for this simple feature.
Ideally I would like to include some tests as well.

@sebakerckhof
Copy link
Collaborator

That was the idea, but since we haven't heard any feedback in the meteor issue, I'd say it's safe to move forward.

@voodooattack
Copy link

Any news on this?

@tonysamperi
Copy link

Ups?

@sattes-faction
Copy link

Is there any progress going on here?

@tonysamperi
Copy link

Actually I don't use this stuff ahahaha

@elliottregan
Copy link

Webpack uses the main property in package.json to decide which file to import. This allows you to import .css or .scss files, whichever is deemed the main file by the package maintainers.

I came across this issue looking for another solution, so I'm not familiar with how Meteor handles packages, but I'm sure you could emulate something similar in package.js.

@sebakerckhof
Copy link
Collaborator

Fixed per 4.14.1

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

No branches or pull requests

6 participants