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

Feature Request: Use Different Resolver Configuration when Finding Targets of @import Directives #493

Closed
mvastola opened this issue Sep 20, 2017 · 4 comments

Comments

@mvastola
Copy link

So I'm a fairly new convert to webpack/yarn -- but an experienced web/rails coder (where I'd been using sprockets). As I am retrofitting my already-existing site with webpack, I'm repeatedly running into one particular annoyance with my codebase though, which leads me to a suggestion that I think would apply to/benefit all users to help include modules in a more robust fashion.

Specifically, the path resolution performed when using an @import directives in a sass stylesheet seems to be a bit less intelligent than what I was used to. In particular, the resolver seems to use the same settings that are used when resolving javascripts and, indeed, any other file.

Firstly, this means that all sorts of non-CSS-ish file extensions are tried in a fixed universal order. This order, by default, appears to have scripts, followed by stylesheets, followed by images. As it's common for package developers to have a .css file and a .js file with the same basename, this requires explicitly specifying the relative path (with extension) within the module of any files one might want to include. The first part of my suggestion would be to only look at a customizable list of extensions when resolving @imports.

Secondly, many npm modules, in their package.json, specify a style key. If this were read, this would allow, for instance @import '~module-name';. Currently the use of this syntax is not possible if the module contains javascript that is at index.js or else is specified by the main key in package.json. I would suggest this be consulted.

@alexander-akait
Copy link
Member

@jhnns friendly ping

@artemjackson
Copy link

artemjackson commented Feb 26, 2018

@evilebottnawi

Secondly, many npm modules, in their package.json, specify a style key. If this were read, this would allow, for instance @import '~module-name';. Currently the use of this syntax is not possible if the module contains javascript that is at index.js or else is specified by the main key in package.json. I would suggest this be consulted.

Is there any progress on it?

@alexander-akait
Copy link
Member

@artemjackson no, but PR welcome, many works around webpack@4 😞

@alexander-akait
Copy link
Member

Close in favor #556, #535 and sass field in package.json

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

No branches or pull requests

3 participants