| 36 | name: 'ns-ensure-hoisted-theme-link', |
| 37 | enforce: 'pre', |
| 38 | buildStart() { |
| 39 | try { |
| 40 | const appNodeModules = path.join(projectRoot, 'node_modules'); |
| 41 | if (!existsSync(appNodeModules)) { |
| 42 | mkdirSync(appNodeModules, { recursive: true }); |
| 43 | } |
| 44 | const linkPath = path.join(appNodeModules, 'nativescript-theme-core'); |
| 45 | const needsLink = !existsSync(linkPath) || !lstatSync(linkPath).isSymbolicLink(); |
| 46 | if (needsLink) { |
| 47 | try { |
| 48 | symlinkSync(themeCoreRoot!, linkPath, 'dir' as any); |
| 49 | } catch {} |
| 50 | } |
| 51 | // Create generic css symlinks (core.light.css -> core.light.<platform>.css) if missing |
| 52 | const cssDir = path.join(linkPath, 'css'); |
| 53 | if (existsSync(cssDir)) { |
| 54 | const files = readdirSync(cssDir); |
| 55 | const platformSuffix = platform === 'android' ? '.android.css' : '.ios.css'; |
| 56 | for (const f of files) { |
| 57 | const m = f.match(/^(.*)\.(android|ios)\.css$/); |
| 58 | if (!m) continue; |
| 59 | const base = m[1]; |
| 60 | const generic = path.join(cssDir, base + '.css'); |
| 61 | if (!existsSync(generic)) { |
| 62 | const platformFile = path.join(cssDir, base + platformSuffix); |
| 63 | if (existsSync(platformFile)) { |
| 64 | try { |
| 65 | symlinkSync(platformFile, generic); |
| 66 | } catch {} |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } catch {} |
| 72 | }, |
| 73 | }; |
| 74 | } |
| 75 | |