Skip to content
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
This repository was archived by the owner on Aug 28, 2026. It is now read-only.

[Discussion] Deprecate :local #308

Closed

Description

@geelen

In my mind, it makes more sense to consider local-scope (and CSS Modules by extension) as something that's always on or always off.

I'm seeing a lot of folks hitting the problem where they enable ?modules and then want to include non-local CSS (e.g. #253) but never in the same file. I think @chrislloyd's suggestion in #287 is a better approach, so you can configure two instances of css-loader, one local and one global, maybe having ".module.css" be local and ".css" be global (like gatsbyjs/gatsby#193).

In global CSS files, then, I don't see any reason to keep :local, except that that was how CSS Modules got started in the first place. But I'm interested in having a discussion about this because I want to know if anyone's still using :local and feels it should be kept.

Activity

  1. joshwnj commented on Jul 27, 2016

    @joshwnj

    I agree, we can reduce some confusion by having 1 less keyword.

    I can see a (rare) use case for wanting to opt-out within a css module by using :global, but I haven't come across any place where it makes sense to opt-in to :local within a css file intended to be global.

  2. gaearon commented on Jul 28, 2016

    @gaearon
    Contributor

    We also have this problem in https://github.com/facebookincubator/create-react-app: we intentionally don’t support CSS modules but people work around this by using :local. Which means changes to our CSS pipeline could break them in the future.

  3. markdalgleish commented on Jul 29, 2016

    @markdalgleish
    Contributor

    I think we should deprecate it. It's totally vestigial, not something that we should encourage people to use going forward.

  4. geelen commented on Jul 29, 2016

    @geelen
    Author

    Cool. I'll make a PR.

  5. added a commit that references this issue on Jul 29, 2016
    f070f6b
  6. Jessidhia commented on Aug 16, 2016

    @Jessidhia

    I actually have an instance in my css-modules-using code where I had to use :global .global-selector :local .local-selector; the case itself is a bit strange, and really should be avoided in "proper" code, but removing :local might make incremental adoption of modules in existing codebases harder.

    I am definitely not using :local in any files that are not local-by-default, though; only to override when nested inside a :global.

  7. tiagocpontesp commented on Jan 22, 2017

    @tiagocpontesp

    In global CSS files, then, I don't see any reason to keep :local

    It's late. Perhaps I'm not reading this correctly.

    I've had to turn off the modules option to achieve this pattern for my components:

    :local(.component)   // ---- the only mangled/imported classname
       & .nested_child   // ---- nested and unchanged 
          ..rules
    

    I noticed some suggestions of sprinkling :globals on nested selectors within :locals-by-default, but it didn't seem to work, and seems less legible (several nested, vs one parent).
    If this PR goes against this, here's my -1.

  8. alexander-akait commented on Feb 15, 2018

    @alexander-akait
    Member

    Thanks everyone, it is out of scope css-loader, please recreate issue in css modules repo, it is their rfc.

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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions