Rsbuild Types
This section describes some of the type definitions provided by the Rsbuild.
RsbuildInstance
The type of Rsbuild instance, corresponding to the return value of the createRsbuild method.
import type { RsbuildInstance } from '@rsbuild/core';
let rsbuild: RsbuildInstance;
RsbuildConfig
The type of Rsbuild configuration.
import type { RsbuildConfig } from '@rsbuild/core';
const config: RsbuildConfig = {
// ...
};
You can also import the type definitions of each field in the Rsbuild config:
import type {
DevConfig,
HtmlConfig,
ToolsConfig,
SourceConfig,
OutputConfig,
SecurityConfig,
PerformanceConfig,
} from '@rsbuild/core';
NormalizedConfig
The type of Rsbuild configuration after normalization, corresponding to the return value of the getNormalizedConfig method.
import type { NormalizedConfig } from '@rsbuild/core';
const config: NormalizedConfig = api.getNormalizedConfig();
You can also import the type definitions of each field in the normalized config:
import type {
NormalizedDevConfig,
NormalizedHtmlConfig,
NormalizedToolsConfig,
NormalizedSourceConfig,
NormalizedOutputConfig,
NormalizedSecurityConfig,
NormalizedPerformanceConfig,
} from '@rsbuild/core';
RsbuildContext
The type of the context property in the Rsbuild instance.
import type { RsbuildContext } from '@rsbuild/core';
const context: RsbuildContext = rsbuild.context;
RsbuildPlugin
The type of Rsbuild plugin.
import type { RsbuildPlugin } from '@rsbuild/core';
const myPlugin: RsbuildPlugin = {
name: 'my-plugin',
setup() {},
};
RsbuildPluginAPI
The type of the api
object passed into the setup
function in the Rsbuild plugin.
import type { RsbuildPluginAPI } from '@rsbuild/core';
const myPlugin = {
name: 'my-plugin',
setup(api: RsbuildPluginAPI) {},
};
RsbuildTarget
The type of build target.
import type { RsbuildTarget } from '@rsbuild/core';
CreateRsbuildOptions
The param type of createRsbuild method.
import type { CreateRsbuildOptions } from '@rsbuild/core';
InspectConfigOptions
The param type of rsbuild.inspectConfig method.
import type { InspectConfigOptions } from '@rsbuild/core';