| 1554 | postcssPlugins.unshift( |
| 1555 | (await importPostcssImport()).default({ |
| 1556 | async resolve(id, basedir, _importOptions, atRule) { |
| 1557 | const publicFile = checkPublicFile( |
| 1558 | id, |
| 1559 | environment.getTopLevelConfig(), |
| 1560 | ) |
| 1561 | if (publicFile) { |
| 1562 | return publicFile |
| 1563 | } |
| 1564 | |
| 1565 | const resolved = await atImportResolvers.css( |
| 1566 | environment, |
| 1567 | id, |
| 1568 | class="cm">// The `source` is only absent for an `@import` injected by another plugin |
| 1569 | class="cm">// (a node with no source), in which case the resolver falls back to |
| 1570 | class="cm">// the project root. |
| 1571 | atRule.source?.input.file, |
| 1572 | ) |
| 1573 | |
| 1574 | if (resolved) { |
| 1575 | return path.resolve(resolved) |
| 1576 | } |
| 1577 | |
| 1578 | class="cm">// postcss-import falls back to `resolve` dep if this is unresolved, |
| 1579 | class="cm">// but we've shimmed to remove the `resolve` dep to cut on bundle size. |
| 1580 | class="cm">// warn here to provide a better error message. |
| 1581 | if (!path.isAbsolute(id)) { |
| 1582 | environment.logger.error( |
| 1583 | colors.red( |
| 1584 | `Unable to resolve \`@import class="st">"${id}"\` from ${basedir}`, |
| 1585 | ), |
| 1586 | ) |
| 1587 | } |
| 1588 | |
| 1589 | return id |
| 1590 | }, |
| 1591 | async load(id) { |
| 1592 | const code = await fs.promises.readFile(id, class="st">'utf-8') |
| 1593 | const lang = CSS_LANGS_RE.exec(id)?.[1] as CssLang | undefined |