How to use the csso.translate function in csso

To help you get started, we’ve selected a few csso examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alexjlockwood / ShapeShifter / src / app / scripts / parsers / svgo / svgo.ts View on Github external
csso.walk(itemRulesetNodeCloned, _fetchDeclarations);
      csso.walk(inlineCssAst, _fetchDeclarations);

      // sort by !important(ce)
      var mergedDeclarationsSorted = stable(mergedDeclarations, function (declarationA, declarationB) {
        var declarationAScore = ~~declarationA.data.value.important, // (cast boolean to number)
          declarationBScore = ~~declarationB.data.value.important; //  "
        return (declarationAScore - declarationBScore);
      });

      // to css
      for (var mergedDeclarationsSortedIndex in mergedDeclarationsSorted) {
        var declaration = mergedDeclarationsSorted[mergedDeclarationsSortedIndex];
        newInlineCssAst.declarations.insert(declaration);
      }
      var newCss = csso.translate(newInlineCssAst);

      elInlineStyleAttr.value = newCss;
      selectedEl.addAttr(elInlineStyleAttr);
    }

    if (removeMatchedSelectors && selectedEls !== null && selectedEls.length > 0) {
      // clean up matching simple selectors if option removeMatchedSelectors is enabled
      selectorItem.rulesetNode.selector.selectors.remove(selectorItem.simpleSelectorItem);
    }
  }

  var styleItemIndex: any = 0,
    styleItem: any = {};
  for (styleItemIndex in styleItems) {
    styleItem = styleItems[styleItemIndex];
github alexjlockwood / ShapeShifter / src / app / scripts / parsers / svgo / svgo.ts View on Github external
var selectorItemsMqs = selectorItems.filter(function (selectorItem) {
    if (selectorItem.atRuleExpNode === null) {
      return true;
    }
    var mqStr = csso.translate(selectorItem.atRuleExpNode);
    return useMqs.indexOf(mqStr) > -1;
  });
github montagejs / mop / lib / transform / css.js View on Github external
}
        }
    }
    try {
        ast = CSSO.compress(ast);
    } catch (error) {
        config.out.warn("CSS compression error: ");
        config.out.warn(error.message);
    }
    try {
        ast = CSSO.cleanInfo(ast);
    } catch (error) {
        config.out.warn("CSS clean info error:");
        config.out.warn(error.message);
    }
    return CSSO.translate(ast);
}
github montagejs / mop / lib / transform / css.js View on Github external
try {
        ast = CSSO.compress(ast);
    } catch (error) {
        config.out.warn("CSS compression error: " + file.path);
        config.out.warn(error.message);
    }

    try {
        ast = CSSO.cleanInfo(ast);
    } catch (error) {
        config.out.warn("CSS clean info error: " + file.path);
        config.out.warn(error.message);
    }

    return CSSO.translate(ast);
}
github basisjs / basisjs / tools / build / build.js View on Github external
{
                  cssSourceClassNames[identName] = ident;
                  ident[3] = 1;
                }
                else
                {
                  part[2] = cssSourceClassNames[identName];
                  cssSourceClassNames[identName][3]++;
                }
              }
            }
            break;

          case 'uri':

            treeConsole.log('+ ' + csso.translate(csso.cleanInfo(token)));
            resourceUriMap.push({
              baseURI: baseURI,
              token: token
            });

            break;

          default:

            walkTree(token, 2);

            break;
        }
      }
    }

csso

CSS minifier with structural optimisations

MIT
Latest version published 2 years ago

Package Health Score

79 / 100
Full package analysis