How to use the icss-utils.replaceSymbols function in icss-utils

To help you get started, we’ve selected a few icss-utils 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 makuga01 / dnsFookup / FE / node_modules / postcss-modules-values / src / index.js View on Github external
it well get picked up by the replacement stuff */
    const 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 */
    ICSSUtils.replaceSymbols(css, definitions);

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

    /* Add import rules */
    importAliases.reverse().forEach(({ path, imports }) => {
      const importRule = postcss.rule({
        selector: `:import(${path})`,
        raws: { after: '\n' }
github css-modules / postcss-icss-values / src / index.js View on Github external
icssImports[parsed.path],
            aliases
          );
        }
      } else {
        result.warn(`Invalid value definition "${atrule.params}"`, {
          node: atrule
        });
      }
    }
    atrule.remove();
  });

  const scopedAliases = getScopedAliases(result.messages, valuesExports);

  replaceSymbols(css, Object.assign({}, valuesExports, scopedAliases));

  Object.keys(icssExports).forEach(key => {
    icssExports[key] = replaceValueSymbols(icssExports[key], scopedAliases);
  });

  css.prepend(
    createICSSRules(icssImports, Object.assign({}, icssExports, valuesExports))
  );

  result.messages.push(...getMessages(valuesExports));
});
github kaliberjs / build / library / postcss-plugins / postcss-import-export-parser.js View on Github external
({ loadExports }) => async function process(css, result) {
    const { icssExports, icssImports } = extractICSS(css)

    const importedValues = await resolveImportedValues(icssImports, loadExports)

    replaceSymbols(css, importedValues)

    Object.entries(icssExports).forEach(([key, rawValue]) => {
      const value = replaceValueSymbols(rawValue, importedValues)
      result.messages.push({
        plugin,
        type: 'export',
        item: { key, value },
      })
    })
  }
)

icss-utils

ICSS utils for postcss ast

ISC
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis