Skip to content

getLocalIdent not working #389

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

Closed
Shuumatsu opened this issue Dec 9, 2016 · 11 comments
Closed

getLocalIdent not working #389

Shuumatsu opened this issue Dec 9, 2016 · 11 comments

Comments

@Shuumatsu
Copy link

I'm using css-loader@0.26.1 which is the latest version and Webpack@2.1.0-beta.25.

My css file loaders configuration is below

{
          test: /\.css$/,
          use: [
            { loader: 'style-loader' },
            {
              loader: 'css-loader',
              options: {
                module: true,
                // getLocalIdent: (loaderContext, localIdentName, localName, options) => `${loaderContext}-${localIdentName}-${localName}-${options}`,
                getLocalIdent: function (loaderContext, localIdentName, localName, options) {
                  console.log(arguments)
                  return 'whatever_random_class_name'
                },
                localIdentName: '[path]---[name]---[local]---[hash:base64:5]'
              }
            },
            { loader: 'postcss-loader' }
          ]
        },

no output in the console, the function is not even called

@nowaalex
Copy link

nowaalex commented Dec 9, 2016

+1

3 similar comments
@tonyhb
Copy link

tonyhb commented Dec 9, 2016

+1

@fengyun2
Copy link

+1

@faceyspacey
Copy link

+1

@Lodin
Copy link

Lodin commented Dec 12, 2016

In accordance with results of my exploration there is no function getLocalIdent in query object in loader.js. Looks like webpack2 converts everything in the query field to a JSON string before using query in loader, and that strips everything except JSON-compatible data.

Hope it will help.

hh9527 added a commit to hh9527/css-loader that referenced this issue Dec 14, 2016
@soluml
Copy link

soluml commented Dec 27, 2016

Tested this with latest Webpack (as of this writing, 2.2.0-rc.2) and I'm getting the same issues. getLocalIdent is completely ignored.

@fengyun2
Copy link

css-loader@0.23.1 which is the latest version and Webpack@2.1.0-beta.28.
localIdentName: [path]---[name]---[local]---[hash:base64:5] 中的 path 没法识别

@huarse
Copy link

huarse commented Jan 21, 2017

+ 1

@TanaseHagi
Copy link

++ 1

@nshoes
Copy link

nshoes commented Feb 14, 2017

+1

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Apr 18, 2017

Fixed by either installing webpack >= v2.2.1 or adding an ident to the loader options

{ 
     loader: 'css-loader', 
     options: {
        ident: 'css'
        ...options
     }
}

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