Replies: 4 comments 31 replies
-
Hmmm. Think I might have just got something working here. Assets are expected to appear in the "public" directory, which is in the same directory as the executable after deferencing symlinks. This seems a bit yuck actually, would prefer it supported looking for these files at a path given by an runtime environment variable. But might be workable. Continuing my hackish commands above: cp dist/* $PWD/target/server-dev/public What confused me a lot is that curl doesn't work (or rather only works for static assets):
But accessing the same page from the web browser works. Now the web site loads, and the sample echo test seems to work properly. What doesn't work: Accessing the static files referenced in the rust code. Which isn't surprising. Probably not a big deal, I don't really need this functionality. But would be nice. Wonder if there is some command I can run to build just the static files (and nothing else). |
Beta Was this translation helpful? Give feedback.
-
Oh, I suspect the key here is manganis_cli_support I see docs here, but I think they might be outdated: I think this might be more current: And this example script: It looks like it takes the rust build artifacts and somehow generates assets from them. Or something like that. |
Beta Was this translation helpful? Give feedback.
-
Front end really wants to connect to |
Beta Was this translation helpful? Give feedback.
-
I'm glad I'm not the only one looking into how to build a fullstack application with nix. packages.default = let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
rev = self'.shortRev or self'.dirtyShortRev or "dirty";
in pkgs.rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = "${cargoToml.package.version}-${rev}";
src = ./.;
strictDeps = true;
buildInputs = rustBuildInputs;
nativeBuildInputs = [ rustToolchain ];
buildPhase = ''
cargo build --release --features web --target wasm32-unknown-unknown
cargo build --release --features server
'';
installPhase = ''
mkdir -p $out/bin
cp -r target $out/target
ln -s $out/target/release/$pname $out/bin/$pname
'';
cargoLock.lockFile = ./Cargo.lock;
}; I'm at the point where this works to build both the server and the wasm front end, and looks like I need to do the wasm bindgen as comparing the directory structure to target/dx/$pname/release/web which as you've discovered as well has a binary named server and a public directory with the assets. |
Beta Was this translation helpful? Give feedback.
-
This might seem crazy, but wondering if this is possible to build the full stack web app without the dx CLI?
I don't care about the hot reload stuff, I think the dx CLI is required for this.
But I think it should be possible to get everything else working.
I have been able to manually build the wasm and the server, but not sure how to point the server at the assets including the wasm.
This is the silly hack I have tried so far (copied from a working yew project; but probably wrong for dioxus):
(this is just a simple build from a dixous template; can but it on github if this would help)
Why?
Because I prefer to have an understanding of what is going on behind the scenes.
Because
dx
seems like a development tool, not really a good tool for making automatic official releases.Because dx-cli under nixos seems to be broken and insists on using the wrong version of wasm-bindgen. dioxus-cli: new project uses wrong version of wasm-bindgen NixOS/nixpkgs#365271
I tried with nixos unstable which has 0.6.0, but that wants to use wasm-bindgen 0.2.97 for some reason even though I have wasm-bindgen 0.2.99, and it isn't possible to downgrade rust to use 0.2.97 either (things depend on 0.2.99 being installed).
Because when building a nixos package, nixos prohibits builds downloading random files from the Internet, so we really should use the existing in process for building rust wasm files. (It is possible that you might be able to get it to run the dx command here, but sure about this).
Also:
I have been able to get the front end only stuff up running. But would really like to get the fullstack thing running.
The built in assets support might be an issue, I didn't notice that until recently. But I could skip using that.
Beta Was this translation helpful? Give feedback.
All reactions