root

Specify the project root directory. Can be an absolute path, or a path relative to process.cwd().

The value of Rsbuild root is also be passed to the context configuration of Rspack.

TIP

The value of root does not affect the path of the .env file, as the .env file is resolved before the Rsbuild configuration file.

Rsbuild CLI supports using the --root option to specify the root directory, which can affect the path of the .env file. See "CLI" for more details.

Example

  • Relative path:
rsbuild.config.ts
export default {
  root: './foo',
};
  • Absolute path:
rsbuild.config.ts
import { join } from 'node:path';

export default {
  root: join(__dirname, 'foo'),
};
ON THIS PAGE