index.js
function renameClassNode(value, sourcePath, opts) {
  // Generate hashes
  var className = value,
      compositeHash = loaderUtils.getHashDigest( (sourcePath ? sourcePath + className : className), opts.hashType, opts.digestType, opts.maxLength),
      classHash = loaderUtils.getHashDigest( className, opts.hashType, opts.digestType, opts.maxLength),
      sourcePathHash = (sourcePath ? loaderUtils.getHashDigest( sourcePath, opts.hashType, opts.digestType, opts.maxLength) : ''),
      newClassName;
  // Check classname format type
  if (typeof opts.classnameFormat === 'string') {
    // Process classname as template
    newClassName = opts.classnameFormat
      .replace(/\[classname\]/gi, className)
      .replace(/\[hash\]/gi, compositeHash)
      .replace(/\[classnamehash\]/gi, classHash)
      .replace(/\[sourcepathash\]/gi, sourcePathHash);
  } else if (typeof opts.classnameFormat === 'function') {
    // Get new classname from callback
    newClassName = opts.classnameFormat(className, sourcePath);
  } else {
    // Keep classname
    newClassName = className;
  }
  // Return generated replacement classname
  return newClassName;
}
function renameClassNode(value, sourcePath, opts) {
  // Generate hashes
  var className = value,
      compositeHash = loaderUtils.getHashDigest( (sourcePath ? sourcePath + className : className), opts.hashType, opts.digestType, opts.maxLength),
      classHash = loaderUtils.getHashDigest( className, opts.hashType, opts.digestType, opts.maxLength),
      sourcePathHash = (sourcePath ? loaderUtils.getHashDigest( sourcePath, opts.hashType, opts.digestType, opts.maxLength) : ''),
      newClassName;
  // Check classname format type
  if (typeof opts.classnameFormat === 'string') {
    // Process classname as template
    newClassName = opts.classnameFormat
      .replace(/\[classname\]/gi, className)
      .replace(/\[hash\]/gi, compositeHash)
      .replace(/\[classnamehash\]/gi, classHash)
      .replace(/\[sourcepathash\]/gi, sourcePathHash);
  } else if (typeof opts.classnameFormat === 'function') {
    // Get new classname from callback
    newClassName = opts.classnameFormat(className, sourcePath);
  } else {
    // Keep classname
    newClassName = className;
  }
  // Return generated replacement classname
  return newClassName;
}
function renameClassNode ( value , sourcePath , opts ) { // Generate hashes var className = value , compositeHash = loaderUtils . getHashDigest ( ( sourcePath ? sourcePath + className : className ) , opts . hashType , opts . digestType , opts . maxLength ) , classHash = loaderUtils . getHashDigest ( className , opts . hashType , opts . digestType , opts . maxLength ) , sourcePathHash = ( sourcePath ? loaderUtils . getHashDigest ( sourcePath , opts . hashType , opts . digestType , opts . maxLength ) : '' ) , newClassName ; // Check classname format type if ( typeof opts . classnameFormat === 'string' ) { // Process classname as template newClassName = opts . classnameFormat . replace ( / \[classname\] / gi , className ) . replace ( / \[hash\] / gi , compositeHash ) . replace ( / \[classnamehash\] / gi , classHash ) . replace ( / \[sourcepathash\] / gi , sourcePathHash ) ; } else if ( typeof opts . classnameFormat === 'function' ) { // Get new classname from callback newClassName = opts . classnameFormat ( className , sourcePath ) ; } else { // Keep classname newClassName = className ; } // Return generated replacement classname return newClassName ; }
Generates a replacement css classname
@param value Original classname
@param sourcePath Source file's path
@param opts Options object
Generates a replacement css classname