CC 4.0 License

The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.

The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.

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 and output.

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 __dirname as the base directory:

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

In the above example, the main entry will be resolved based on the path.join(__dirname, './src/index.js') path.

ON THIS PAGE