17 lines
971 B
PowerShell
17 lines
971 B
PowerShell
# Same output as build.py, for machines without Python (Windows PowerShell 5.1).
|
|
$root = $PSScriptRoot
|
|
$src = Join-Path $root 'src'
|
|
$utf8 = New-Object System.Text.UTF8Encoding($false)
|
|
$read = { param($p) [System.IO.File]::ReadAllText((Join-Path $src $p), $utf8) }
|
|
$html = & $read 'shell.html'
|
|
$html = $html.Replace('{{STYLE}}', (& $read 'space.css'))
|
|
$html = $html.Replace('{{SCRIPT}}', (& $read 'atmos.js') + "`n" + (& $read 'space.js'))
|
|
$assets = Join-Path (Split-Path (Split-Path $root)) 'web\public\assets'
|
|
foreach ($pair in @(@('ROOM', 'her-room.jpg'), @('TALK', 'her-talk.jpg'))) {
|
|
$b64 = [Convert]::ToBase64String([System.IO.File]::ReadAllBytes((Join-Path $assets $pair[1])))
|
|
$html = $html.Replace('{{' + $pair[0] + '}}', 'data:image/jpeg;base64,' + $b64)
|
|
}
|
|
if ($html.Contains('{{')) { throw 'Unreplaced placeholder' }
|
|
[System.IO.File]::WriteAllText((Join-Path $root 'index.html'), $html, $utf8)
|
|
"Built offline index.html ($($utf8.GetByteCount($html)) bytes)"
|