CLI

Rspeedy comes with a lightweight CLI that includes commands such as dev and build.

Using the global Rspeedy version

You can invoke Rspeedy using npx rspeedy, but it's more convenient to also install it globally so that it's always available in your shell PATH:

# Install the Rspeedy globally
npm install --global @lynx-js/rspeedy
What if the globally installed Rspeedy binary is the wrong version?

Just like Rush, Rspeedy implements a "version selector" feature that will automatically discover your local node_modules folder and invoke ./node_modules/.bin/rspeedy, ensuring that the correct version is used.

Using Node.js TypeScript support

If the version of Node.js you are using supports the --experimental-transform-types(v22.7.0) or --experimental-strip-types(v22.6.0) flag, you can use the built-in TS transformation of Node.js.

package.json
{
  "build": "NODE_OPTIONS=--experimental-transform-types rspeedy build"
}

rspeedy -h

To view all available CLI commands, run the following command in the project directory:

rspeedy -h

The output is shown below:

➜ rspeedy --help

Usage: rspeedy <command> [options]

Options:
  -V, --version      output the version number
  --unmanaged        Force to use the unmanaged version of Rspeedy, instead of the locally installed.
  -h, --help         display help for command

Commands:
  build [options]    Build the project in production mode
  dev [options]      Run the dev server and watch for source file changes while serving.
  inspect [options]  View the Rsbuild config and Rspack config of the project.
  preview [options]  Preview the production build outputs locally.
  help [command]     display help for command

rspeedy dev

The rspeedy dev command is used to start a local dev server and compile the source code for development.

➜ rspeedy dev --help

Usage: rspeedy dev [options]

Options:
  -c --config <config>  specify the configuration file, can be a relative or absolute path
  -h, --help            display help for command

The dev server will restart automatically when the content of the configuration file is modified.

rspeedy build

The rspeedy build command will build the outputs for production in the dist/ directory by default.

➜ rspeedy build --help

Usage: rspeedy build [options]

Options:
  -c --config <config>  specify the configuration file, can be a relative or absolute path
  -h, --help            display help for command

rspeedy preview

The rspeedy preview command is used to preview the production build outputs locally. Note that you need to execute the rspeedy build command beforehand to generate the build outputs.

➜ rspeedy preview --help

Usage: rspeedy preview [options]

Options:
  -c --config <config>  specify the configuration file, can be a relative or absolute path
  -h, --help            display help for command
TIP

The preview command is only used for local preview. Do not use it for production servers, as it is not designed for that.

rspeedy inspect

The rspeedy inspect command is used to view the Rspeedy config and Rspack config of the project.

➜ rspeedy inspect --help

Usage: rspeedy inspect [options]

View the Rsbuild config and Rspack config of the project.

Options:
  --mode <mode>         specify the mode of Rsbuild (default: "development")
  --output <output>     specify inspect content output path
  --verbose             show full function definitions in output
  -c --config <config>  specify the configuration file, can be a relative or absolute path
  -h, --help            display help for command

When you run the command rspeedy inspect in the project root directory, the following files will be generated in the dist/.rspeedy directory of the project:

  • rspeedy.config.js: Represents the Rspeedy configuration used during the build.
  • rsbuild.config.mjs: Represents the Rsbuild configuration used during the build.
  • rspack.config.lynx.mjs: Represents the Rspack configuration used during the build.
➜ rspeedy inspect

Inspect config succeed, open following files to view the content:

  - Rspeedy Config: /project/dist/.rsbuild/rspeedy.config.mjs
  - Rspack Config (lynx): /project/dist/.rsbuild/rspack.config.lynx.mjs

Inspect Rspeedy config succeed, open following files to view the content:

  - Rspeedy: /Users/colin/rspeedy/examples/react/dist/rspeedy-rspack/.rsbuild/rspeedy.config.js

Specifying Mode

By default, the inspect command outputs the configuration for the development mode. You can add the --env production option to output the configuration for the production mode:

rspeedy inspect --mode production

Verbose content

By default, the inspect command omits the content of functions in the configuration object. You can add the --verbose option to output the complete content of functions:

rspeedy inspect --verbose
Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.