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.

[2.0.0] getLocalIdent validation #862

Closed

Description

@gpoitch
  • Operating System: macOS 10.14.1
  • Node Version: 11.2.0
  • NPM Version: 6.4.1
  • webpack Version: 4.27.1
  • css-loader Version: 2.0.0

Expected Behavior

Previously, if getLocalIdent returned a falsey value, css-loader would fallback to using localIdentName

Actual Behavior

css-loader throws an error:

ValidationError: CSS Loader Invalid Options
options.getLocalIdent should pass "instanceof" keyword validation

Code

const isProduction = false

const cssLoader = {
  loader: 'css-loader',
  options: {
    modules: true,
    localIdentName: '[local]__[hash:base64:3]',
    getLocalIdent: isProduction && function() {
       return 'foo' // other logic here, but just return a string for purpose of issue
    }
  }
}

How Do We Reproduce?

Run tests with those loader options

Activity

  1. alexander-akait commented on Dec 7, 2018

    @alexander-akait
    Member

    @gpoitch what you expected from getLocalIdent when you set it false?

  2. gpoitch commented on Dec 7, 2018

    @gpoitch
    Author

    I expect it to fallback to using localIdentName.
    Worked around it by explicitly setting to undefined instead of a falsey value.

    getLocalIdent: isProduction ? function(){ /*...*/ } : undefined
  3. alexander-akait commented on Dec 7, 2018

    @alexander-akait
    Member

    @gpoitch maybe we can accept false value for easy configuration, what do you think?

  4. gpoitch commented on Dec 7, 2018

    @gpoitch
    Author

    @evilebottnawi yes, that'd be nice, as it worked in 1.x. Otherwise that is a tiny breaking change

  5. alexander-akait commented on Dec 7, 2018

    @alexander-akait
    Member

    @gpoitch let's mark it as bug and fix in 2.0.1

  6. added this to the 2.0.1 milestone on Dec 7, 2018
  7. alexander-akait commented on Dec 7, 2018

    @alexander-akait
    Member

    previous we don't have schema options and tests so i can lose something, sorry

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions