Here is part of config
{
test: /\.(scss|sass|css)$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
localIdentName: '[folder]_[path]__[name]_[local]__[hash:base64:16]',
modules: 1,
importLoaders: 1
}
},
{
loader: 'postcss-loader'
}
]
}
structure of project is
components
MyComponent
index.js
style.js
I need in [folder] tag to avoid same classes names in different css/sass files
P.S.
Why we can't do something like this in getLocalIdent file:
...
options.content = options.hashPrefix + request + "+" + loaderContext.resourcePath + '#' + localName;
...
Are you using LoaderOptionsPlugin? Try disable LoaderOptionsPlugin and see if [folder] is still empty.
I believe this is related to #340
Hi rnons, I had the same problem, before I disabled LoaderOptionsPlugin, with the localIdentName, thanks!
Also, @MikeLP if you are using LoaderOptionsPlugin ensure you have context.
My code with LoaderOptionsPlugin and correct localIdentName:
new webpack.LoaderOptionsPlugin({
options: {
context: __dirname,
postcss: [
// bunch of plugins
],
},
}),
@keske OMG CONTEXT IN OPTIONS!!!! THANK YOU
@keske Thanks.
Most helpful comment
Also, @MikeLP if you are using
LoaderOptionsPluginensure you havecontext.My code with
LoaderOptionsPluginand correctlocalIdentName: