-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frontend website strategy #53
Comments
I like that. |
running 'npm build' that is. |
OK, great! I'll see if I can cook up a nice working example with Parcel + React and then we can talk about an official buildpack / Dockerfile or something that would run |
As a first baby step, I've made a very minimal React + Parcel example featuring:
To deploy it's enough to do Here's the code: https://github.com/metakermit/responder-react I haven't touched any Responder stuff so far, but I see that there are going to be some challenges:
Starlette has options for some of these things, but I think they aren't all exposed in Responder. As a side-note, I did solve some of these issues with Django & Whitenoise here, so I have some ideas for how these things could be solved. Not sure what the best approach would be in Responder architecture-wise. |
I have a prototype available here: #72 |
@metakermit off master, you can now run static from api = responder.API(static_route="/") |
Wow, that's a great start. I'll continue working on this tonight and see if I can get the cli to build the frontend if it's there (e.g. a package.json is present) and copy whatever's in dist to the static folder. |
Now, off master, if you do this: api.add_route("/", static=True)
|
Now, off master, if you have a |
this still leaves
but I think that's a small workaround, for now. |
@kennethreitz Perfect, that solves most of the SPA requirements, I think 🎉 I'll test it and if it works, we can later see if we want to have some order of precedence in the future, e.g. in the
|
@metakermit that's exactly the flow that's in place. |
I don't know much about single-page web apps, but this will always result in a 200 response from the server, even if it appears as though it's 404. |
unless there's a specific 404 view defined |
cool, i'll ship it |
v0.1.0 released, which includes this. |
Sure, I think that's fine. I think the way it's done is that if the frontend doesn't find its template, it renders a 404 page. Traditionally this is done by setting nginx to forward everything to index.html, but with Responder we don't need nginx 🙂 Awesome! 🚀 |
Just an update that I've managed to update https://github.com/metakermit/responder-react to seamlessly deploy to Heroku with everything working as expected 🎉 It took some custom Parcel flags, a custom Heroku build step and an app.json that configures multiple buildpacks, but now you can simply hit that "Deploy to Heroku" button and you have a super smooth Responder + React SPA experience 🙂 |
Really like the concepts inside responder! I'm wondering what would be the strategy for integrating frontend websites? I see webpack is mentioned in the README. Would something like https://parceljs.org/ also be interesting? Since the choice of frontend framework / tooling is pretty tangental to other things in responder, would it maybe make sense to just round up a few example folders or cookiecutters and link them up? E.g.
One thing that would make sense to standardise IMHO would be the build command in package.json. E.g. always have an
npm run build
command for building the frontend. That way a standard responder Heroku buildpack / Dockerfile could be used for deploying the webapp no matter which frontend stack is used.The text was updated successfully, but these errors were encountered: