index.js
function renameNodes(nodes, sourcePath, opts, mappings) {
  return nodes.map(function(node) {
    // Process CSS node
    if (node.type === 'class') {
      // Process "class" node
      var orgValue = node.value,
          newValue = renameClassNode(node.value, sourcePath, opts);
      // Edit node and store mapping of classname renaming
      node.value = mappings[orgValue] = newValue;
    } else if (node.type === 'pseudo' && node.value === ':not') {
      // Process ":not([selector])" pseudo node
      renameNodes(node.nodes, sourcePath, opts, mappings);
    } else if (node.type === 'selector') {
      // Rename selector nodes
      renameNodes(node.nodes, sourcePath, opts, mappings)
    }
  });
}
function renameNodes(nodes, sourcePath, opts, mappings) {
  return nodes.map(function(node) {
    // Process CSS node
    if (node.type === 'class') {
      // Process "class" node
      var orgValue = node.value,
          newValue = renameClassNode(node.value, sourcePath, opts);
      // Edit node and store mapping of classname renaming
      node.value = mappings[orgValue] = newValue;
    } else if (node.type === 'pseudo' && node.value === ':not') {
      // Process ":not([selector])" pseudo node
      renameNodes(node.nodes, sourcePath, opts, mappings);
    } else if (node.type === 'selector') {
      // Rename selector nodes
      renameNodes(node.nodes, sourcePath, opts, mappings)
    }
  });
}
function renameNodes ( nodes , sourcePath , opts , mappings ) { return nodes . map ( function ( node ) { // Process CSS node if ( node . type === 'class' ) { // Process "class" node var orgValue = node . value , newValue = renameClassNode ( node . value , sourcePath , opts ) ; // Edit node and store mapping of classname renaming node . value = mappings [ orgValue ] = newValue ; } else if ( node . type === 'pseudo' && node . value === ':not' ) { // Process ":not([selector])" pseudo node renameNodes ( node . nodes , sourcePath , opts , mappings ) ; } else if ( node . type === 'selector' ) { // Rename selector nodes renameNodes ( node . nodes , sourcePath , opts , mappings ) } } ) ; }
Renames all classnames in css nodes
@param nodes css nodes
@param sourcePath Source file's path
@param opts Options object
@param mappings Classname to renamed classname mappings repository
@return {*} Renamed css nodes
Renames all classnames in css nodes