> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# Context


- Type: `string`
- Default:`process.cwd()`


The `context` configuration is used to set the base directory for Rspack builds.

`context` is an absolute path that is used as the base path for relative paths in Rspack configurations such as [entry](/config/entry.md) and [output](/config/output.md).

By default, Rspack uses the current working directory of the Node.js process as the base directory. In most cases, it is recommended to set a base directory manually, rather than relying on the current working directory of Node.js.

## Example

For example, you can use the configuration file's directory as the base directory:


**ESM**

```js title="rspack.config.mjs"
export default {
  context: import.meta.dirname,
  entry: {
    main: './src/index.js',
  },
};
```


**CJS**

```js title="rspack.config.cjs"
module.exports = {
  context: __dirname,
  entry: {
    main: './src/index.js',
  },
};
```


In the above example, the `main` entry resolves to `src/index.js` relative to the configuration file's directory.


This page is adapted from [webpack documentation](https://webpack.js.org/configuration/entry-context/#context) under the [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), with modifications.

