Trying to use css modules with SSR. My css loader configs:
// client
test: /\.css$/,
loader: ExtractTextPlugin.extract(
'style',
'css?modules&localIdentName=[hash]&camelCase&importLoaders=1!postcss'
)
// server
test: /\.css$/,
loader: 'css/locals?modules&localIdentName=[hash]&camelCase'
It generates different hashes for server and client. Hence React throw an error:

How a hash generate, based on what? What could I be doing wrong?
UPD
This problem is somehow connected to entry point in webpack server bundle config:
// with this working well
context: path.join(__dirname, 'server'),
entry: {
server: './index.js'
},
// with this generating wrong hashes
context: __dirname,
entry: {
server: './server/index.js'
},
The path of the resource relative to context is used to create the hash, so this is expected behaviour. If But, if I'm following the code correctly you can pass a context in the loader query, i.e.:
'css?context=../server'
But the easiest thing to do would probably be to make sure the shared files are at the same place relative to both client and server.
If someone is dummy like me and unable to solve it, just pass { context:
@osenvosem @arvigeus Can your do PR in docs about this?
Had a similar issue. Using webpack4. Found this fixed context in our case:

Most helpful comment
The path of the resource relative to
contextis used to create the hash, so this is expected behaviour. If But, if I'm following the code correctly you can pass acontextin the loader query, i.e.:But the easiest thing to do would probably be to make sure the shared files are at the same place relative to both client and server.