gulp/util.js
function dedupeCss() {
  const prefixRegex = /-(webkit|moz|ms|o)-.+/;

  return insert.transform(function(contents) {
    // Parse the CSS into an AST.
    const parsed = postcss.parse(contents);

    // Walk through all the rules, skipping comments, media queries etc.
    parsed.walk(function(rule) {
      // Skip over any comments, media queries and rules that have less than 2 properties.
      if (rule.type !== 'rule' || !rule.nodes || rule.nodes.length < 2) return;

      // Walk all of the properties within a rule.
      rule.walk(function(prop) {
        // Check if there's a similar property that comes after the current one.
        const hasDuplicate = validateProp(prop) && _.find(rule.nodes, function(otherProp) {
          return prop !== otherProp && prop.prop === otherProp.prop && validateProp(otherProp);
        });

        // Remove the declaration if it's duplicated.
        if (hasDuplicate) {
          prop.remove();

          gutil.log(gutil.colors.yellow(
            'Removed duplicate property: "' +
            prop.prop + ': ' + prop.value + '" from "' + rule.selector + '"...'
          ));
        }
      });
    });

    // Turn the AST back into CSS.
    return parsed.toResult().css;
  });

  // Checks if a property is a style declaration and that it
  // doesn't contain any vendor prefixes.
  function validateProp(prop) {
    return prop && prop.type === 'decl' && ![prop.prop, prop.value].some(function(value) {
      return value.indexOf('-') > -1 && prefixRegex.test(value);
    });
  }
}
function dedupeCss() {
  const prefixRegex = /-(webkit|moz|ms|o)-.+/;

  return insert.transform(function(contents) {
    // Parse the CSS into an AST.
    const parsed = postcss.parse(contents);

    // Walk through all the rules, skipping comments, media queries etc.
    parsed.walk(function(rule) {
      // Skip over any comments, media queries and rules that have less than 2 properties.
      if (rule.type !== 'rule' || !rule.nodes || rule.nodes.length < 2) return;

      // Walk all of the properties within a rule.
      rule.walk(function(prop) {
        // Check if there's a similar property that comes after the current one.
        const hasDuplicate = validateProp(prop) && _.find(rule.nodes, function(otherProp) {
          return prop !== otherProp && prop.prop === otherProp.prop && validateProp(otherProp);
        });

        // Remove the declaration if it's duplicated.
        if (hasDuplicate) {
          prop.remove();

          gutil.log(gutil.colors.yellow(
            'Removed duplicate property: "' +
            prop.prop + ': ' + prop.value + '" from "' + rule.selector + '"...'
          ));
        }
      });
    });

    // Turn the AST back into CSS.
    return parsed.toResult().css;
  });

  // Checks if a property is a style declaration and that it
  // doesn't contain any vendor prefixes.
  function validateProp(prop) {
    return prop && prop.type === 'decl' && ![prop.prop, prop.value].some(function(value) {
      return value.indexOf('-') > -1 && prefixRegex.test(value);
    });
  }
}
function dedupeCss ( ) { const prefixRegex = / -(webkit|moz|ms|o)-.+ / ; return insert . transform ( function ( contents ) { // Parse the CSS into an AST. const parsed = postcss . parse ( contents ) ; // Walk through all the rules, skipping comments, media queries etc. parsed . walk ( function ( rule ) { // Skip over any comments, media queries and rules that have less than 2 properties. if ( rule . type !== 'rule' || ! rule . nodes || rule . nodes . length < 2 ) return ; // Walk all of the properties within a rule. rule . walk ( function ( prop ) { // Check if there's a similar property that comes after the current one. const hasDuplicate = validateProp ( prop ) && _ . find ( rule . nodes , function ( otherProp ) { return prop !== otherProp && prop . prop === otherProp . prop && validateProp ( otherProp ) ; } ) ; // Remove the declaration if it's duplicated. if ( hasDuplicate ) { prop . remove ( ) ; gutil . log ( gutil . colors . yellow ( 'Removed duplicate property: "' + prop . prop + ': ' + prop . value + '" from "' + rule . selector + '"...' ) ) ; } } ) ; } ) ; // Turn the AST back into CSS. return parsed . toResult ( ) . css ; } ) ; // Checks if a property is a style declaration and that it // doesn't contain any vendor prefixes. function validateProp ( prop ) { return prop && prop . type === 'decl' && ! [ prop . prop , prop . value ] . some ( function ( value ) { return value . indexOf ( '-' ) > - 1 && prefixRegex . test ( value ) ; } ) ; } }
Removes duplicated CSS properties.
Removes duplicated CSS properties .