Rsbuild provides a comprehensive JavaScript API for developers to build higher-level tools or frameworks on top of Rsbuild.
Rsbuild's JavaScript API can be used in Node.js, Deno, or Bun.
Here is a basic example of how to access the Rsbuild JavaScript API.
You need to install the @rsbuild/core
package:
You can call the createRsbuild method to create an Rsbuild instance:
The createRsbuild
method provides some options, which you can learn more about in the API - createRsbuild.
The Rsbuild instance provides several methods that you can use according to your scenario.
For local development, we recommend using the rsbuild.startDevServer method, which starts a local dev server.
After successfully starting the dev server, you will see the following logs:
For production deployment, we recommend using the rsbuild.build method, which builds the production outputs.
For more introduction of Rsbuild instance methods, please read the Rsbuild Instance chapter.
After completing these three steps, you have learned the basic usage of Rsbuild. Next, you can customize the build process through Rsbuild plugins and configurations.
Rsbuild provides exports in both ES Modules and CommonJS formats:
We recommend using the ES modules format, which better aligns with community standards.