How to use the icss-replace-symbols function in icss-replace-symbols

To help you get started, we’ve selected a few icss-replace-symbols 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 css-modules / css-modules-require-hook / src / parser.js View on Github external
return css => {
    // https://github.com/postcss/postcss/blob/master/docs/api.md#inputfile
    const file = css.source.input.file;
    const translations = {};
    const exportTokens = {};

    css.walkRules(importRegexp, rule => {
      const exports = fetch(RegExp.$1, file);

      rule.walkDecls(decl => translations[decl.prop] = exports[decl.value]);
      rule.remove();
    });

    replaceSymbols(css, translations);

    css.walkRules(exportRegexp, rule => {
      rule.walkDecls(decl => {
        forEach(translations, (value, key) => decl.value = decl.value.replace(key, value));
        exportTokens[decl.prop] = decl.value;
      });

      rule.remove();
    });

    css.tokens = exportTokens;
  };
});
github Dajust / reduxTrello / node_modules / postcss-modules-values / src / index.js View on Github external
}
  })

  /* We want to export anything defined by now, but don't add it to the CSS yet or
   it well get picked up by the replacement stuff */
  let exportDeclarations = Object.keys(definitions).map(key => postcss.decl({
    value: definitions[key],
    prop: key,
    raws: { before: "\n  " }
  }))

  /* If we have no definitions, don't continue */
  if (!Object.keys(definitions).length) return

  /* Perform replacements */
  replaceSymbols(css, definitions)

  /* Add export rules if any */
  if (exportDeclarations.length > 0) {
    let exportRule = postcss.rule({
      selector: `:export`,
      raws: { after: "\n" }
    })
    exportRule.append(exportDeclarations)
    css.prepend(exportRule)
  }

  /* Add import rules */
  importAliases.reverse().forEach(({ path, imports }) => {
    let importRule = postcss.rule({
      selector: `:import(${path})`,
      raws: { after: "\n" }
github sx1989827 / DOClever / Client / node_modules / postcss-modules-values / src / index.js View on Github external
}
  })

  /* We want to export anything defined by now, but don't add it to the CSS yet or
   it well get picked up by the replacement stuff */
  let exportDeclarations = Object.keys(definitions).map(key => postcss.decl({
    value: definitions[key],
    prop: key,
    raws: { before: "\n  " }
  }))

  /* If we have no definitions, don't continue */
  if (!Object.keys(definitions).length) return

  /* Perform replacements */
  replaceSymbols(css, definitions)

  /* Add export rules if any */
  if (exportDeclarations.length > 0) {
    let exportRule = postcss.rule({
      selector: `:export`,
      raws: { after: "\n" }
    })
    exportRule.append(exportDeclarations)
    css.prepend(exportRule)
  }

  /* Add import rules */
  importAliases.reverse().forEach(({ path, imports }) => {
    let importRule = postcss.rule({
      selector: `:import(${path})`,
      raws: { after: "\n" }

icss-replace-symbols

Replacing symbols during the linking phase of ICSS

ISC
Latest version published 7 years ago

Package Health Score

67 / 100
Full package analysis