This section introduces how to deploy the build outputs of Rsbuild as a static site.
Before starting the deployment, you need to understand some background information:
The build commands provided by Rsbuild:
rsbuild build
command beforehand to generate the build outputs.The preview command is only used for local preview. Do not use it for production servers, as it is not designed for that.
Rsbuild's build outputs typically includes HTML, JS, CSS, and other assets, and is output to the dist
directory by default. The name and structure of the dist directory can be changed using some configuration options. See the Output Files section for more information.
We can divide the build output into two parts: HTML files and static assets.
.html
suffix in the output directory, which usually need to be deployed on the server.static
directory of the output folder, which contains assets such as JavaScript, CSS, and images. They can be deployed either on the server or on a CDN.If the static assets are deployed in a subdirectory of the server, you can configure output.assetPrefix as the base path:
If you want to place these static assets on a CDN for better performance, rather than directly on the server like HTML, you will need to configure the output.assetPrefix to the CDN address to allow the application to properly reference these static assets.
In this way, when referencing static assets in HTML, the specified prefix will be automatically added, for example:
GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub
The following are step-by-step examples on how to deploy on GitHub Pages.
github-pages.yml
(you can adjust the content and name of the file as needed).https://<USERNAME>.github.io/<REPO_NAME>/
to view the deployed page.Netlify Core is a frontend cloud solution for developers to build and deploy future-proof digital solutions with modern, composable tooling.
Netlify provides a detailed guide, you can follow the instructions in Netlify - Add new site, set up some basic information, and then you can start the deployment.
You need to configure the following two fields:
npm run build
.dist
.Then click on the Deploy site button to start the deployment.
If you want to make your sites accessible at your own domain names, you can configure it in the "Domain management" section of Netlify.
Detailed guide: Netlify - Custom domains.
Vercel is a platform for developers that provides the tools, workflows, and infrastructure you need to build and deploy your web apps faster, without the need for additional configuration.
Vercel provides a detailed guide that you can follow Vercel - Projects to create a project in your dashboard and configure some basic information to start deployment.
You only need to configure the fields under "Build and Output Settings":
dist
.Then click the Deploy button to start the deployment.
If you want to make your sites accessible at your own domain names, you can configure it in the "Domains" section of Vercel.
Detailed guide: Vercel - Domains.
Cloudflare Pages is a static site hosting platform provided by Cloudflare.
You can follow the Cloudflare Pages - Git integration guide to integrate with Git and deploy your site to Cloudflare Pages.
When configuring, you need to fill in the following fields in the "Build settings":
npm run build
.dist
.Then click on the Save and Deploy button to start the deployment.