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

dont work for css-loader@^2 #103

Closed
VadimZvf opened this issue Apr 3, 2019 · 3 comments
Closed

dont work for css-loader@^2 #103

VadimZvf opened this issue Apr 3, 2019 · 3 comments

Comments

@VadimZvf
Copy link

VadimZvf commented Apr 3, 2019

classNames dont match with css-loader@2.0.0 or above
with css-loader@1.0.1 all fine

@felixcatto
Copy link

With css-loader@3.6.0 all works fine
I use generateScopedName: '[local]--[hash:base64:5]', in server babel config
and localIdentName: '[local]--[hash:base64:5]', in client (webpack) config

@felixcatto
Copy link

It turns out, in some cases classNames really don't match. But you can generate them by yourself.
someFIle.js

const crypto = require('crypto');

const generateScopedName = (localName, resourcePath) => {
  const getHash = value => crypto.createHash('sha256').update(value).digest('hex');
  const hash = getHash(`${resourcePath}${localName}`).slice(0, 5);
  return `${localName}__${hash}`;
};

server babel config

[
  'css-modules-transform',
  {
    generateScopedName,
    devMode: true,
  },
],

client webpack config

{
  loader: 'css-loader',
  options: {
    modules: {
      getLocalIdent: ({ resourcePath }, _, localName) => generateScopedName(localName, resourcePath),
    },
  },
},

@suhanw
Copy link

suhanw commented Jan 3, 2021

classNames don't match for me either, I'm using css-loader@5.0.1 and babel-plugin-css-modules-transform@1.6.2

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

3 participants