oracolo icon indicating copy to clipboard operation
oracolo copied to clipboard

At least some documentation how to build the static index.html

Open jooray opened this issue 5 months ago • 7 comments

I don't know how to build the index.html. I hacked it a bit, this is what I did:

This produces dist/index.html:

npm install
npm install -D vite@5 @sveltejs/vite-plugin-svelte@3
npx vite build

The output is placed in dist/.

I then used https://github.com/jooray/html-resource-embedder to convert it into a self-contained HTML file.

Is there a nicer way to produce the dist/index.html?

jooray avatar Aug 18 '25 15:08 jooray

Run the server, visit the webpage generated for your npub, then download the generated HTML. It should be already a self-contained blob.

We should probably make a CLI option for streamlining that process.

fiatjaf avatar Aug 18 '25 17:08 fiatjaf

Run the server - how? No mention how to do it in the README.md.

Assuming it is:

go build
BASE_DOMAIN=localhost PORT=45070 ./oracolo

but opening http://localhost says "missing CNAME record for localhost:45070" when I open the page. Same for the subdomains. Is there a way to run it without setting up DNS servers? I just want to get the HTML.

jooray avatar Aug 18 '25 19:08 jooray

Yeah, sorry about that.

To run the server you should call just dev (with https://just.systems/) and then you should be able to access the rendered websites at http://npub1blabla.localhost:45070/

You can then either copy the HTML manually or click on the button at the bottom of the page for downloading an HTML file. You can also do that directly on https://npub1blabla.oracolo.me/ without having to run anything locally.

fiatjaf avatar Aug 18 '25 20:08 fiatjaf

Now I realized that embedding all the JS and CSS in the same HTML file might be what is causing slow startup times on production websites @dtonon.

Maybe we should not do that, and instead only do it when the user clicks on the "Download" button at the bottom?

fiatjaf avatar Aug 18 '25 20:08 fiatjaf

The reason I want to run things locally is that if I change something, I want to test it or deploy it in my file.

I still have the same problem:

$ BASE_DOMAIN=localhost just dev &
12:59PM INF running on http://localhost:45070
$ curl -o- 'http://npub1blabla.localhost:45070/'
missing CNAME record for npub1blabla.localhost:45070

This "missing CNAME record" is actually returned by the webserver.

I will write documentation about this, when I solve it.

jooray avatar Aug 19 '25 11:08 jooray

Try with BASE_DOMAIN=localhost:45070.

fiatjaf avatar Aug 19 '25 13:08 fiatjaf

Now I realized that embedding all the JS and CSS in the same HTML file might be what is causing slow startup times on production websites @dtonon. Maybe we should not do that, and instead only do it when the user clicks on the "Download" button at the bottom?

Why slow startup times? I briefly tested the procedure and the generation and download (the single file is ~500KB) seems quite fast for a non cached setup, less than 1 sec loading time.

dtonon avatar Aug 20 '25 09:08 dtonon