Repository navigation
Loco with Angular #218
Replies: 4 comments 4 replies
|
This is more of a tutorial on how I set up an Angular frontend with the Loco backend. I hope this can help someone :) |
|
Hello, @LimpidCrypto! This is fantastic! I'm confident we can find a valuable use for it. Why did you close the discussions i think we have a lot to talk :)
|
Hey @kaplanelad this was just meant to be a short tutorial. I'm happy to discuss about it :) This is the first time I use Loco. I was just about to start a similar project, as I couldn't find anything similar, which is to Rust what Laravel is to PHP. So yesterday I discovered this awesome framework. I haven't seen the todo-list repo yet. Thanks for pointing it out to me :) |
|
Awesome, thanks for putting this together! Cannot wait to see this for Flutter ;) |
Uh oh!
There was an error while loading. Please reload this page.
Loco with Angular
Overview
.devcontainer/DockerfilefrontenddirectoryconfigEdit
.devcontainer/DockerfileFROM mcr.microsoft.com/vscode/devcontainers/rust:0-1 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends postgresql-client \ && cargo install sea-orm-cli \ && chown -R vscode /usr/local/cargo + # Install Node.js and npm + RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ + && apt-get install -y nodejs + + # Install Angular CLI + RUN npm install -g @angular/cli COPY .env /.envReopen the project in the Dev Container
With VSCode it is super easy to reopen and run the project in a Dev Container.
VSCode will open the project in the Docker container. This can take a while when it is built for the first time.
Delete
frontenddirectoryLoco come with a Vite React frontend. We can delete the whole directory because the Angular CLI will set up everything we need
Generate new Angular frontend
From the project root execute
ng new frontendand follow the instructionsBuild frontend
Run
ng buildto build the Angular frontendEdit
configAs you may have noticed Angular has built the frontend into
frontend/dist/frontend/browser. We need to set that path for Loco config. Navigate toconfig/development.ymland set the following config:server.middlewares.static.folder.path: "frontend/dist/frontend/browser"server.middlewares.static.fallback: "frontend/dist/frontend/browser/index.html"Start Loco
Run
cargo loco startand open http://localhost:3000/You should now see the Angular starter Website :)
All reactions