So i am using webpack and css-loader with localIndentName for server side rendering my app with react. I am using css modules to import css for sepecific components. Now the problem is while importing styles in a component the server is returning the css mapped object inside a local key so server is unable to find styles.className while on the client side everything works fine.
this is my edited rules config for both server and client
{
test: /\.css$/,
use: [
{
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[local]__[hash:base64:4],
camelCase: true
}
}
],
}
this is server server is getting when i console log any imported style
[ [ 107,
'',
'' ],
toString: [Function],
i: [Function],
locals: { 'class-name': 'class-name__3WnY' } ]
This is what my client is complaining
Warning: Prop `className` did not match. Server: "" Client: "class-name__3WnY"
Why such behavior?