How to use the icss-utils.extractICSS 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 mrmckeb / typescript-plugin-css-modules / src / helpers / getClasses.ts View on Github external
// Will strip `~` from imports, unless followed by a slash.
          data: css.replace(/(@import ['"])~(?!\/)/gm, '$1'),
          indentedSyntax: fileType === FileTypes.sass,
          includePaths: [filePath, 'node_modules', ...(includePaths || [])],
          ...sassOptions,
        })
        .css.toString();
    } else {
      transformedCss = css;
    }

    const processedCss = processor.process(transformedCss, {
      from: fileName,
    });

    return processedCss.root ? extractICSS(processedCss.root).icssExports : {};
  } catch (e) {
    console.log(e);
    logger.error(e);
    return {};
  }
};
github css-modules / postcss-icss-selectors / src / index.js View on Github external
module.exports = postcss.plugin(plugin, (options = {}) => (css, result) => {
  const { icssImports, icssExports } = extractICSS(css);
  const generateScopedName =
    options.generateScopedName ||
    genericNames("[name]__[local]---[hash:base64:5]");
  const input = (css && css.source && css.source.input) || {};
  const aliases = {};
  walkRules(css, rule => {
    const getAlias = name => {
      if (aliases[name]) {
        return aliases[name];
      }
      // icss-value contract
      const valueMsg = getValue(result.messages, name);
      if (valueMsg) {
        aliases[valueMsg.name] = name;
        return name;
      }
github makuga01 / dnsFookup / FE / node_modules / postcss-modules-local-by-default / index.js View on Github external
return function(css) {
    const { icssImports } = extractICSS(css, false);
    const localAliasMap = getImportLocalAliases(icssImports);

    css.walkAtRules(function(atrule) {
      if (/keyframes$/i.test(atrule.name)) {
        const globalMatch = /^\s*:global\s*\((.+)\)\s*$/.exec(atrule.params);
        const localMatch = /^\s*:local\s*\((.+)\)\s*$/.exec(atrule.params);
        let globalKeyframes = globalMode;
        if (globalMatch) {
          if (pureMode) {
            throw atrule.error(
              '@keyframes :global(...) is not allowed in pure mode'
            );
          }
          atrule.params = globalMatch[1];
          globalKeyframes = true;
        } else if (localMatch) {
github kaliberjs / build / library / postcss-plugins / postcss-export-parser.js View on Github external
() => function process(css, result) {
    const { icssExports, icssImports } = extractICSS(css)

    if (Object.keys(icssImports).length) {
      console.log('Found imports, do we need to process them?')
      console.log(JSON.stringify(icssExports, null, 2))
    }

    Object.entries(icssExports).forEach(([key, value]) => {
      result.messages.push({
        plugin,
        type: 'export',
        item: { key, value },
      });
    });
  }
)
github didi / mpx / packages / webpack-plugin / lib / wxss / processCss.js View on Github external
values.nodes[0].nodes.shift()
        var mediaQuery = Tokenizer.stringifyValues(values)

        if (isUrlRequest(url, options.root)) {
          url = loaderUtils.urlToRequest(url, options.root)
        }

        importItems.push({
          url: url,
          mediaQuery: mediaQuery
        })
        rule.remove()
      })
    }

    var icss = icssUtils.extractICSS(css)
    exports = icss.icssExports
    Object.keys(icss.icssImports).forEach(function (key) {
      var url = loaderUtils.parseString(key)
      Object.keys(icss.icssImports[key]).forEach(function (prop) {
        imports['$' + prop] = importItems.length
        importItems.push({
          url: url,
          export: icss.icssImports[key][prop]
        })
      })
    })

    Object.keys(exports).forEach(function (exportName) {
      exports[exportName] = replaceImportsInString(exports[exportName])
    })
github css-modules / postcss-icss-values / src / index.js View on Github external
module.exports = postcss.plugin(plugin, () => (css, result) => {
  const { icssImports, icssExports } = extractICSS(css);
  const valuesExports = {};
  const getAliasName = createGenerator();
  const addExports = (node, name, value) => {
    if (isForbidden(name)) {
      result.warn(`Dot and hash symbols are not allowed in value "${name}"`, {
        node
      });
    }
    if (valuesExports[name]) {
      result.warn(`"${name}" value already declared`, { node });
    }
    valuesExports[name] = replaceValueSymbols(value, valuesExports);
  };

  css.walkAtRules("value", atrule => {
    if (atrule.params.indexOf("@value") !== -1) {
github sx1989827 / DOClever / Desktop / node_modules / css-loader / lib / processCss.js View on Github external
return;
				}
				values.nodes[0].nodes.shift();
				var mediaQuery = Tokenizer.stringifyValues(values);
				if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
					url = loaderUtils.urlToRequest(url, options.root);
				}
				importItems.push({
					url: url,
					mediaQuery: mediaQuery
				});
				rule.remove();
			});
		}

		var icss = icssUtils.extractICSS(css);
		exports = icss.icssExports;
		Object.keys(icss.icssImports).forEach(function(key) {
			var url = loaderUtils.parseString(key);
			Object.keys(icss.icssImports[key]).forEach(function(prop) {
				imports["$" + prop] = importItems.length;
				importItems.push({
					url: url,
					export: icss.icssImports[key][prop]
				});
			})
		});

		Object.keys(exports).forEach(function(exportName) {
			exports[exportName] = replaceImportsInString(exports[exportName]);
		});
github sx1989827 / DOClever / node_modules / css-loader / lib / processCss.js View on Github external
values.nodes[0].nodes.shift();
				var mediaQuery = Tokenizer.stringifyValues(values);

				if(loaderUtils.isUrlRequest(url, options.root)) {
					url = loaderUtils.urlToRequest(url, options.root);
				}

				importItems.push({
					url: url,
					mediaQuery: mediaQuery
				});
				rule.remove();
			});
		}

		var icss = icssUtils.extractICSS(css);
		exports = icss.icssExports;
		Object.keys(icss.icssImports).forEach(function(key) {
			var url = loaderUtils.parseString(key);
			Object.keys(icss.icssImports[key]).forEach(function(prop) {
				imports["$" + prop] = importItems.length;
				importItems.push({
					url: url,
					export: icss.icssImports[key][prop]
				});
			})
		});

		Object.keys(exports).forEach(function(exportName) {
			exports[exportName] = replaceImportsInString(exports[exportName]);
		});
github sx1989827 / DOClever / Client / node_modules / css-loader / lib / processCss.js View on Github external
return;
				}
				values.nodes[0].nodes.shift();
				var mediaQuery = Tokenizer.stringifyValues(values);
				if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
					url = loaderUtils.urlToRequest(url, options.root);
				}
				importItems.push({
					url: url,
					mediaQuery: mediaQuery
				});
				rule.remove();
			});
		}

		var icss = icssUtils.extractICSS(css);
		exports = icss.icssExports;
		Object.keys(icss.icssImports).forEach(function(key) {
			var url = loaderUtils.parseString(key);
			Object.keys(icss.icssImports[key]).forEach(function(prop) {
				imports["$" + prop] = importItems.length;
				importItems.push({
					url: url,
					export: icss.icssImports[key][prop]
				});
			})
		});

		Object.keys(exports).forEach(function(exportName) {
			exports[exportName] = replaceImportsInString(exports[exportName]);
		});
github xxxgitone / learningProcess / WebPack-Beginner / node_modules / css-loader / lib / processCss.js View on Github external
return;
				}
				values.nodes[0].nodes.shift();
				var mediaQuery = Tokenizer.stringifyValues(values);
				if(loaderUtils.isUrlRequest(url, options.root) && options.mode === "global") {
					url = loaderUtils.urlToRequest(url, options.root);
				}
				importItems.push({
					url: url,
					mediaQuery: mediaQuery
				});
				rule.remove();
			});
		}

		var icss = icssUtils.extractICSS(css);
		exports = icss.icssExports;
		Object.keys(icss.icssImports).forEach(function(key) {
			var url = loaderUtils.parseString(key);
			Object.keys(icss.icssImports[key]).forEach(function(prop) {
				imports["$" + prop] = importItems.length;
				importItems.push({
					url: url,
					export: icss.icssImports[key][prop]
				});
			})
		});

		Object.keys(exports).forEach(function(exportName) {
			exports[exportName] = replaceImportsInString(exports[exportName]);
		});

icss-utils

ICSS utils for postcss ast

ISC
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis