Anidetrix / rollup-plugin-styles

🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
https://anidetrix.github.io/rollup-plugin-styles
MIT License
242 stars 43 forks source link

The hash token in generateScopedName doesn't include the class name in the generated hash #167

Open frankieyan opened 3 years ago

frankieyan commented 3 years ago

I'm trying to generate classnames similar to webpack's localIdentName where its default is a single hash: https://webpack.js.org/loaders/css-loader/#localidentname

With a single hash token provided to generateScopedName, it looks like it's generated off of the file name and the entire contents of the css file, so every classname within the same document will receive the same hash:

https://github.com/Anidetrix/rollup-plugin-styles/blob/5e877a862c9b349b8714dff8b61a8c8fbf64a775/src/loaders/postcss/modules/generate.ts#L15

Would it make sense to use something like hasher(`${base}:${css}:${local}`) here so class names are unique?