dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Fix static generation serve

Open ealmloff opened this issue 1 year ago • 4 comments

Static generation was looking for an environment variable that the CLI no longer sets when serving. This PR fixes that issue and makes dx serve just work

ealmloff avatar Aug 27 '24 14:08 ealmloff

Testing this PR on the repo linked in https://github.com/DioxusLabs/docsite/issues/305 ...

dx build --release fails with:

[..]
static-generation build: Build progress 100%
static-generation build: Build progress 100%
static-generation build: --- Optimizing Assets ---
2024-08-27T15:27:46.574076Z  INFO dx::builder::cargo: Copying public assets to the output directory...
2024-08-27T15:27:46.574113Z  INFO dx::builder::cargo: 🚩 Build completed: [/Users/srid/code/dioxus-static-site/dist]
static-generation build: --- Finished ---
Error: 🚫 Building project failed:

Caused by:
    0: Failed to post process build
    1: task 13 panicked

srid avatar Aug 27 '24 15:08 srid

dx serve seems to work at first

image

But it eventually crashes with:

image

srid avatar Aug 27 '24 15:08 srid

With 0c88b39, dx build --release succeeds, but the static files cannot be opened in the browser when served with a plain http-server (it just serves the file statically from ./dist, like GitHub pages would). I get a page with title, but the body is empty; with these console errors:

image

dx serve on the other hand, continues to fail (I mean it exists promptly, after printing some warnings):

image

Even without --release:

image

@ealmloff Is there something I'm missing here?

srid avatar Aug 27 '24 20:08 srid

dx serve and dx build are kind of confusing for static site generation. Currently build is set up to build the wasm and static site generation binary, but not run it. It should be running it as well. Marking this as a draft until I get more intuitive behavior implemented

ealmloff avatar Aug 27 '24 20:08 ealmloff