-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRepository.imba
More file actions
46 lines (33 loc) · 1.13 KB
/
Repository.imba
File metadata and controls
46 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { readFileSync, existsSync } from 'fs'
import { join } from 'path'
export default class Repository
static manifestCache\ViteManifest|null = null
static def get file\string
const manifest = self.getManifest!
if !manifest
return file
const normalizedFile = file.startsWith('/') ? file.slice(1) : file
if manifest[normalizedFile]
return '/build/' + manifest[normalizedFile].file
if normalizedFile == 'css/app.css'
for [key, value] in Object.entries(manifest)
if key.includes('css/app.css')
return '/build/' + value.file
if normalizedFile == 'js/app.js'
for [key, value] in Object.entries(manifest)
if key.includes('js/app.ts')
return '/build/' + value.file
file
static def getManifest\ViteManifest|null
if self.manifestCache != null
return self.manifestCache
const location = join(process.cwd!, 'public', 'build', '.vite', 'manifest.json')
try
if existsSync(location)
const content = readFileSync(location, 'utf8')
self.manifestCache = content ? JSON.parse(content) : null
else
self.manifestCache = null
catch err
self.manifestCache = null
self.manifestCache