A simple development server built with Rust that serves a Vue.js SPA (Single Page Application).
- Rust-based static file server
- SPA Web App support (here Vue.js but you can test other and make feedbacks)
- Custom web root directory support
server/- Rust backend serverweb/- Vue.js frontend application
- Clone the repository:
git clone https://github.com/ludndev/playground-rust-vuejs-server.git- Build and run the frontend:
cd web
npm ci
npm run build- Run the server:
cd server
cargo run- To run the server with a custom web root directory:
cd server
cargo run -- --dir path/to/web/rootIf you are following this repository structure, no need to set --dir as default dir is set to web/dist.
With Vue.js SPA, you can use the following command to run the server. Note that the --dir option is set to ../web/dist for our demo Vue.js app. Feel free to adapt --dir to your actual path.
cargo run -- --dir ../web/distHere, we are using Next.js as an example. We have used nobruf/shadcn-landing-page. Our implementation may not cover all cases, but it working for our demo app.
Clone the repository in our project root directory to have a structure like this:
.
├── server/
├── shadcn-landing-page/
└── web/We have added to nextConfig in next.config.js :
output: "export", // we have added this line to enable the export mode
distDir: "build", // we have added this line to change the distDir nameto look like this:
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export", // we have added this line to enable the export mode
distDir: "build", // we have added this line to change the distDir name
images: {
remotePatterns: [
{
protocol: "https",
hostname: "i.pravatar.cc",
},
{
protocol: "https",
hostname: "images.unsplash.com",
},
{
protocol: "https",
hostname: "github.com",
},
],
},
};
export default nextConfig;And finally, to run the server:
cargo run -- --dir ./../shadcn-landing-page/buildThis project is licensed under the MIT License - see the LICENSE file for details.