Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 1.36 KB

File metadata and controls

25 lines (16 loc) · 1.36 KB

generic-names

Helper for building generic names, similar to webpack. Designed to be used with postcss‑modules‑scope.

Uses interpolateName from the webpack/loader-utils.

API

var genericNames = require('generic-names');
var generate = genericNames('[name]__[local]___[hash:base64:5]', {
  context: process.cwd()
});

generate('foo', '/case/source.css'); // 'source__foo___3mRq8'

Compatibility

With Webpack's css-loader and babel-plugin-react-css-modules

Starting from version 3.0, this plugin is not compatible with babel-plugin-react-css-modules running under css-modules<3.6.0 due to this update.

Explanation: starting from 3.6.0, css-modules uses \x00 instead of + when generating content.options consumed by Webpack when generating [hash] and [contenthash], as can be seen in this update. As a result, the hash value generated by the react css modules plugin is not the same as the one generated by Webpack's css-loader.