JSON
Rsbuild supports importing JSON files in code, and also supports importing YAML and TOML files, converting them to JSON format.
JSON file
You can import JSON files directly in JavaScript files.
Example
Named import
Rsbuild also supports importing JSON files using named imports:
YAML file
YAML is a data serialization language commonly used for writing configuration files.
Rsbuild provides the @rsbuild/plugin-yaml. After registering the plugin, you can import .yaml or .yml files in JavaScript and they will be automatically converted to JavaScript objects.
Example
TOML file
TOML is a semantically explicit, easy-to-read configuration file format.
Rsbuild provides the @rsbuild/plugin-toml. After registering the plugin, you can import .toml files in JavaScript and it will be automatically converted to JavaScript objects.
Example
Type declaration
When you import YAML or TOML files in TypeScript code, please create a src/env.d.ts file in your project and add the corresponding type declarations.
- Method 1: If the
@rsbuild/corepackage is installed, you can reference the preset types provided by@rsbuild/core:
- Method 2: Manually add the required type declarations:

