react-union
react-union copied to clipboard
How to import external CSS without changing class names
When I try to import CSS from node_modules the loader renames all the class names
I found one workaround here This is what I'm using:
const loadCSS = isServerConfig => ({
module: {
rules: [
{
test: /\.css$/,
oneOf: [{
resourceQuery: /^\?raw$/,
use: [
...(isServerConfig ? [] : [ExtractCSSChunks.loader]),
{
loader: require.resolve('css-loader'),
options: {
onlyLocals: isServerConfig,
},
},
]
}, {
use: [
...(isServerConfig ? [] : [ExtractCSSChunks.loader]),
{
loader: require.resolve('css-loader'),
options: {
modules: {
localIdentName: '[name]__[local]--[hash:base64:5]',
},
onlyLocals: isServerConfig,
},
},
],
}]
},
],
},
});
Is there a better way to do it?