seed-rs / seed-quickstart

Bare essentials to start a Seed app.
https://seed-rs.org/
101 stars 28 forks source link

Mime-Type problem #12

Closed flosse closed 4 years ago

flosse commented 5 years ago

Versions

Steps to reproduce

git clone https://github.com/David-OConnor/seed-quickstart
cd seed-quickstart/
git checkout 2980c62f9f866c3e3e43fddcf13e8add1542036e
cargo make serve

Errors

Firefox: Bildschirmfoto_2019-10-05_17-30-27 Chromium: Bildschirmfoto_2019-10-05_17-30-42

flosse commented 5 years ago

.. after running one cargo make watch it's working.

David-OConnor commented 5 years ago

Unable to repro on my end. This may be related to the hosting's config.

MartinKavik commented 5 years ago

cargo make build is missing in Steps to reproduce. Server then returns 404 or index => MIME text/html. You built / fixed it with watch.

flosse commented 5 years ago

cargo make build is missing in Steps to reproduce. Server then returns 404 or index => MIME text/html. You built / fixed it with watch.

Yes, I expected that cargo make serve invokes a build if it was not executed manually. Like usual Makefiles I don't need to build every single dependency but only call a make my-target

David-OConnor commented 5 years ago

Still can't repro, on Linux/Win/Chrome/FF. Suspect it's a dev-server issue, but can't pin it.

MartinKavik commented 5 years ago

@David-OConnor try to clone this repo into a new empty folder and then run cargo make serve as the first and only command. Or you can delete pkg folder (with compiled wasm and js files) in your project which uses this quickstart and then run cargo make serve. (I can''t try if by myself now because I need to resolve some problems with my SSD..)

David-OConnor commented 5 years ago

Nailed it! I apparently can't follow instructions. I'm not sure how to tackle the misleading error message; leaning towards having it auto-build if it can't find the pkg folder, or perhaps the wasm inside.

Edit: Not sure if there's an easy way to do this, given that makefiles can't execute logic like checking if a folder exists. Having it always build before serve only costs ~1s for me, but dumps a lot in the console. May leave as-is. Thoughts on that?

MartinKavik commented 5 years ago

Some ideas for tasks:

  1. option

    • watch rename to start
    • add start_release
    • remove build and serve from README
  2. option

    • add watch_release
    • update serve to compile and crate wasm
    • add serve_release

etc.. There are more combinations.

MartinKavik commented 5 years ago

Not sure if there's an easy way to do this, given that makefiles can't execute logic like checking if a folder exists.

Maybe it's possible to add checking task as a dependency to serve task, but it seems a little bit over-engineered. I prefer deleting things / code or at least changing.

David-OConnor commented 5 years ago

How about adding a start task that runs build, then serve, and leaving existing build, build_release, and serve unchanged ? Ideally we'd do watch then serve, but these two ongoing tasks appear to not be able to run simultaneously from the naive approach in Makefile.

MartinKavik commented 5 years ago

Ideally we'd do watch then serve,

Yeah, I forgot that watch doesn't start server. I was googling for a while but I don't know how to resolve it properly now, except writing some error-prone custom scripts or something like webpack;s dev-server in Rust...

David-OConnor commented 5 years ago

One approach would be to make a rust Script that runs process::Command for watch and serve, and get cargo-make to run that. Would have to cleverly interlace the streaming outputs. For now, going to go with the start addition to makefile, and push it in the next release, along with the Init change. (ie once the two open Seed PRs are merged). Can you think of a better approach using cargo make alone?

MartinKavik commented 5 years ago

Script that runs process::Command

Maybe you can reuse some code from https://github.com/David-OConnor/seed/blob/master/Makefile.toml#L258. I was fighting with console output in this script, so it maybe helps you a little with cleverly interlace the streaming outputs.

Can you think of a better approach using cargo make alone?

Unfortunately no. If you encounter some problems while writing that script, we can create an issue in cargo-make repo. I also tried to find something like https://www.npmjs.com/package/concurrently in Rust, but no luck (I'm using it for starting server + prerendering in seed-quickstart-webpack).

Ben-PH commented 4 years ago

Nailed it! I apparently can't follow instructions. I'm not sure how to tackle the misleading error message; leaning towards having it auto-build if it can't find the pkg folder, or perhaps the wasm inside.

Edit: Not sure if there's an easy way to do this, given that makefiles can't execute logic like checking if a folder exists. Having it always build before serve only costs ~1s for me, but dumps a lot in the console. May leave as-is. Thoughts on that?

I did exactly the same thing. I'm putting together a PR now that will hopefully make this mistake less likely to be made.

MartinKavik commented 4 years ago

The whole quickstart and README rewritten. It should resolve this issue.

There are still two commands watch and serve for the sake of simplicity, however it should be clear from the README how to use them. Also watch tries to compile the project AFTER the watch init, so it's more comfortable for developers to use.