Rsbuild provides a complete set of JavaScript APIs for developers to build higher level solutions on top of Rsbuild.
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 some methods, which you can use it according to the usage scenarios.
To start local development, it is recommended to use the rsbuild.startDevServer method, which will start a local Dev Server.
After successfully starting Dev Server, you can see the following logs:
To deploy the App to production environment, it is recommended to use the rsbuild.build method, which will build the production outputs.
For more introduction of Rsbuild instance methods, please read the Rsbuild Instance chapter.
After completing the above three steps, you have learned the basic usage of Rsbuild. Next, you can customize the build process through the Rsbuild plugin and Rsbuild configs.
Rsbuild provides exports in both ES Modules and CommonJS formats:
It is recommended to use ES modules format, which is more in line with the community standards.