(root: any)
| 20 | { |
| 21 | postcssPlugin: 'ns-postcss-platform-import-rewrite', |
| 22 | Once(root: any) { |
| 23 | try { |
| 24 | const currentFile: string | undefined = root?.source?.input?.file; |
| 25 | if (!currentFile) return; |
| 26 | const currentDir = path.dirname(currentFile); |
| 27 | root.walkAtRules('import', (rule: any) => { |
| 28 | const m = /^\s*(?:url\()?["]?([^"')]+)["]?\)?/.exec(rule.params || ''); |
| 29 | if (!m) return; |
| 30 | const spec = m[1]; |
| 31 | if (!spec || !(spec.startsWith('.') || spec.startsWith('/'))) return; |
| 32 | if (!spec.endsWith('.css')) return; |
| 33 | const abs = path.isAbsolute(spec) ? spec : path.resolve(currentDir, spec); |
| 34 | if (existsSync(abs)) return; |
| 35 | const ext = platform === 'android' ? '.android.css' : '.ios.css'; |
| 36 | const alt = abs.replace(/\.css$/, ext); |
| 37 | if (existsSync(alt)) { |
| 38 | let rel = path.relative(currentDir, alt).replace(/\\/g, '/'); |
| 39 | if (!rel.startsWith('.')) rel = './' + rel; |
| 40 | rule.params = (rule.params as string).replace(spec, rel); |
| 41 | } |
| 42 | }); |
| 43 | } catch {} |
| 44 | }, |
| 45 | }, |
| 46 | postcssImport({ |
| 47 | resolve(id: string, basedir: string) { |
nothing calls this directly
no test coverage detected