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: import globbing #17

Open
timkelty opened this issue Nov 16, 2014 · 4 comments
Open

Feature request: import globbing #17

timkelty opened this issue Nov 16, 2014 · 4 comments

Comments

@timkelty
Copy link

In transitioning to Rework from Sass, one thing I am missing is the ability to do import globbing (https://github.com/chriseppstein/sass-globbing).

Is this something that could reasonably be added to rework-npm?

@timkelty timkelty changed the title Feature request: globbing Feature request: import globbing Nov 16, 2014
@conradz
Copy link
Contributor

conradz commented Nov 17, 2014

Not really, no, since it uses the exact same import algorithm as Node.js modules use, which does not have import globs. Also, in my experience, import globs in CSS are an anti-pattern, because the ordering of the imports is not well defined. In CSS the order that the files are imported is very important for determining the priority of conflicting properties. When specifically listing each file it is obvious where they will occur in the output.

@timkelty
Copy link
Author

I know what you're saying, but disagree about it being anti-pattern.

If you're writing really modularized css, the import order often really doesn't matter. In addition, if you're writing your css with each component/module as their own file, not having globbing can get pretty tedious.

Since rework-npm wont reimport in the same scope, if you really needed to control order, you could do something like this:

@import "./utilities/first.css"
@import "./utilities/second.css"
@import "./utilities/*.css"
@import "./components/*.css"

If I were to work on a plugin for this, would suggest making it standalone, or a fork of rework-npm, or even perhaps rework-importer? Since I already need and use rework-npm, this is where I'm starting, but I haven't peeked at any code yet. And it seems like using multiple plugins that handle import rules could get messy.

@conradz
Copy link
Contributor

conradz commented Nov 17, 2014

If you make a clean implementation of it while still using the Node.js module resolution algorithm, I would be willing to merge it into this project. But it probably would need to use a fork of resolve, which is what we use to resolve the module path.

@timkelty
Copy link
Author

Cool, I'll work on it! Thanks for the help.

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

2 participants