MCPcopy
hub / github.com/webpack/webpack / processLocalAtRule

Method processLocalAtRule

lib/css/CssParser.js:1554–1636  ·  view source on GitHub ↗
(atRule, options)

Source from the content-addressed store, hash-verified

1552 * @returns {number} position after handling
1553 */
1554 const processLocalAtRule = (atRule, options) => {
1555 let found = false;
1556 for (const cv of A.prelude(atRule)) {
1557 const cvType = A.type(cv);
1558 if (cvType === NodeType.Whitespace) continue;
1559
1560 if (cvType === NodeType.String) {
1561 if (!found && options.string) {
1562 const value = A.unescaped(cv);
1563 const {
1564 start: { line: sl, column: sc },
1565 end: { line: el, column: ec }
1566 } = A.loc(cv);
1567 addCssExport(
1568 sl,
1569 sc,
1570 el,
1571 ec,
1572 value,
1573 value,
1574 [A.start(cv), A.end(cv)],
1575 true,
1576 CssIcssExportDependency.EXPORT_MODE.ONCE
1577 );
1578 found = true;
1579 pure.markLocal();
1580 }
1581 continue;
1582 }
1583
1584 if (cvType === NodeType.Ident) {
1585 if (!found && options.identifier) {
1586 const identifier = A.unescaped(cv);
1587 if (
1588 options.identifier instanceof RegExp &&
1589 options.identifier.test(identifier)
1590 ) {
1591 continue;
1592 }
1593 const {
1594 start: { line: sl, column: sc },
1595 end: { line: el, column: ec }
1596 } = A.loc(cv);
1597 addCssExport(
1598 sl,
1599 sc,
1600 el,
1601 ec,
1602 identifier,
1603 getReexport(identifier),
1604 [A.start(cv), A.end(cv)],
1605 true,
1606 CssIcssExportDependency.EXPORT_MODE.ONCE,
1607 CssIcssExportDependency.EXPORT_TYPE.NORMAL
1608 );
1609 found = true;
1610 pure.markLocal();
1611 }

Callers

nothing calls this directly

Calls 6

unescapedMethod · 0.80
markLocalMethod · 0.80
unescapedNameMethod · 0.80
typeMethod · 0.45
locMethod · 0.45
testMethod · 0.45

Tested by

no test coverage detected