Command line interface
@rspack/cli is the command line tool for Rspack, providing a variety of commands to make working with Rspack easier.
- If you do not have
@rspack/cliinstalled, please read the Quick start section first. - If you are using Rsbuild, please refer to the Rsbuild CLI section.
@rspack/cli is not compatible with webpack-cli, so there will be some differences between the two.
All commands
To view all available CLI commands, run the following command in the project directory:
Common flags
Rspack CLI provides several common flags that can be used with all commands:
All flags in Rspack CLI support the camelCase and kebab-case, for example, both --configLoader and --config-loader are valid.
rspack build
rspack build is used to run Rspack build, which will generate the output files in the output.path directory.
rspack build can be abbreviated as rspack b:
Use the -c or --config flag to specify the configuration file path:
The complete flags are as follows:
rspack dev
rspack dev is used to run Rspack dev server, which will start a local dev server that will listen for file changes and automatically refresh the browser.
Use the -c or --config flag to specify the configuration file path:
rspack dev can be abbreviated as rspack serve or rspack s:
The complete flags are as follows:
rspack preview
rspack preview is used to preview the production build output locally, note that you need to build the output first by running the rspack build command.
The complete flags are as follows:

