Skip to content

Allow 'index' to be a possible file to import #690

Closed

Description

@anthonyshort

It would be great to allow an index.scss file to be imported if a directory is found. Example

@import "./fruits"

If ./fruits is found to be a directory, it would look for ./fruits/index.scss or ./fruits/index.sass.

The reason behind this is to make it easier to consume packages containing Sass files. For example.

Screen Shot 2013-03-20 at 11 07 41 PM

We can then download packages into a directory, add that directory as a single load path and then in our main file we can easily do:

@import "nib-styles-common";
@import "nib-styles-dialog";

Which is a little neater than any alternative.

Activity

  1. anthonyshort commented on Mar 20, 2013

    @anthonyshort
    Author

    I attempted to do a pull request for this, but alas, my skills are weak 😢

  2. chriseppstein commented on Mar 20, 2013

    @chriseppstein

    I love this idea.

  3. nex3 commented on Mar 22, 2013

    @nex3
    Contributor

    This seems reasonable to me.

  4. robwierzbowski commented on Mar 22, 2013

    @robwierzbowski

    Isn't this basically Sass globbing?

  5. anthonyshort commented on Mar 22, 2013

    @anthonyshort
    Author

    Not really. It more like an alias. It could theoretically live anywhere. If Sass packages all do this then there is a guaranteed, single entry point for every library.

  6. chriseppstein commented on Mar 22, 2013

    @chriseppstein

    I think we should make this part of 4.0 when we add our module system. it
    may be better to use a different file name than "index" that is in keeping
    with whatever we come up with for our modules. E.g. _module.s[ac]ss.

  7. robwierzbowski commented on Mar 22, 2013

    @robwierzbowski

    I think I see your point. So the difference is:

    • Sass Globbing: imports all files in a directory or directory tree
    • Index Importing imports only the index (or whatever naming convention is used) in a directory, reducing functionality but enforcing a uniform rule

    If this rule would be for all stylesheets, including site/application stylesheets, _style might be better — index is an odd conflation with html. Chris's suggestion _module works too.

  8. nex3 commented on Mar 22, 2013

    @nex3
    Contributor

    index is nice because it's consistent with conventions used by other languages, but we would want it to be a partial. _index is less similar, so _module might be a better way to go for that reason.

  9. anthonyshort commented on Mar 23, 2013

    @anthonyshort
    Author

    I only suggested index because that is what I'm used to with node and Component. The name doesn't particular matter too much. It would be nice to get this before 4.0 as it seems like it could be trivial to implement and would make using Sass with tools like Bower and Component easier.

  10. anthonyshort commented on Mar 23, 2013

    @anthonyshort
    Author

    @robwierzbowski Globbing won't really work with a module system though. Modules should have a single entry point where they 'export' what consumers need.

  11. robwierzbowski commented on Mar 23, 2013

    @robwierzbowski

    @anthonyshort You're totally right. Took me a min to get my head around it.

  12. robwierzbowski commented on Apr 25, 2013

    @robwierzbowski

    After working with node fort a few weeks, I take back my objections to _index.scss. Of all the options it's now the one I prefer the most 😄.

  13. nwhittaker commented on Dec 29, 2013

    @nwhittaker

    +1

  14. grant commented on Jan 28, 2014

    @grant

    Totally wish I had this feature right now...

  15. jslegers commented on Mar 30, 2014

    @jslegers

    Some people would prefer the name _module.scss. Others would prefer _index.scss, _style.scss, _component.scss, _loader.scss or something else.

    It would be great if the name of the index file could be configured, so we could all use our own personal preference.

  16. 17 remaining items

  17. deleted a comment from dawidk92 on Jul 30, 2017
  18. deleted a comment from tauren on Jul 30, 2017
  19. deleted a comment from adamjgrant on Jul 30, 2017
  20. deleted a comment from gurdiga on Jul 30, 2017
  21. deleted a comment from chrisbuttery on Jul 30, 2017
  22. deleted a comment from alex-milanov on Jul 30, 2017
  23. deleted a comment from tmlbl on Jul 30, 2017
  24. deleted a comment from r-park on Jul 30, 2017
  25. deleted a comment from robertwbradford on Jul 30, 2017
  26. silvandiepen commented on Jul 30, 2017

    @silvandiepen

    Indeed still waiting for this feature. The setup is already ready, only the urls in the main app.scss have to be altered. When is this coming?

  27. nex3 commented on Jul 30, 2017

    @nex3
    Contributor

    I think the labels pretty clearly indicate the status of this proposal: we like the idea, but we don't have the resources to devote to it at present.

  28. added 3 commits that reference this issue on Mar 9, 2018
    ad7760a
    e63b8e1
    b57b973
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wantedplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions