Interface: Dev
The Dev option is used to control the behavior related with development. Including: HMR, DevServer, etc.
Properties
assetPrefix?
optionalassetPrefix?:string|boolean
The Dev.assetPrefix is used to set the URL prefix for static assets during development.
Default Value
Remarks
During rspeedy dev, if this option is not set to false, the dev plugin normalizes it to http://<detected-host>:<port>/ and appends server.base when configured.
The functionality of Dev.assetPrefix is basically the same as the output.publicPath config in Rspack. With the following differences:
-
dev.assetPrefixonly takes effect during development. -
dev.assetPrefixautomatically appends a trailing/by default. -
The value of
dev.assetPrefixis written to theprocess.env.ASSET_PREFIXenvironment variable.
Examples
If dev.assetPrefix is set to true, the URL prefix will be http://<host>:<port>/:
If dev.assetPrefix is set to a string, the value will be used as a prefix and automatically appended to the static resource URL.
The port number that Rspeedy server listens on may change. For example, if the port is in use, Rspeedy will automatically increment the port number until it finds an available port.
To avoid dev.assetPrefix becoming invalid due to port changes, you can use one of the following methods:
-
Enable
server.strictPort. -
Use the
<port>placeholder to refer to the current port number. Rspeedy will replace the placeholder with the actual port number it is listening on.
hmr?
optionalhmr?:boolean
Whether to enable Hot Module Replacement (HMR).
Default Value
Remarks
By default, Rspeedy uses HMR as the preferred method to update modules. If HMR is disabled or cannot be used in certain scenarios, it will automatically fallback to Dev.liveReload.
To completely disable both HMR and live reload, set both dev.hmr and dev.liveReload to false. Then, no WebSocket requests will be made to the dev server on the page, and the page will not automatically refresh when file changes.
Examples
Disable HMR:
Disable both HMR and live reload:
liveReload?
optionalliveReload?:boolean
Whether to enable live reload functionality.
Default Value
Remarks
Live reload is used as a fallback when Dev.hmr is disabled or cannot be used in certain scenarios. When enabled, the page will automatically refresh when source files are changed.
To completely disable both HMR and live reload, set both dev.hmr and dev.liveReload to false. Then, no WebSocket requests will be made to the dev server on the page, and the page will not automatically refresh when file changes.
Examples
Disable live reload:
Disable both HMR and live reload:
progressBar?
optionalprogressBar?:boolean| {id?:string; }
Whether to display progress bar during compilation.
Default Value
Examples
Enable the progress bar.
Modify the progress bar id
To modify the text displayed on the left side of the progress bar, set the id option:
watchFiles?
optionalwatchFiles?:WatchFiles|WatchFiles[]
Watch specified files and directories for changes. When a file change is detected, it can trigger a page reload or restart the dev server.
Default Value
Examples
- Specify the files and directories watched for changes.
- Use chokidar options for watching.
writeToDisk?
optionalwriteToDisk?:boolean| ((filename:string) =>boolean)
Lynx Default Changed
Used to control whether the build artifacts of the development environment are written to the disk.
Default Value
Remarks
This is bypassed to `webpack-dev-middleware`.
Setting writeToDisk: true won't change the behavior of the webpack-dev-middleware, and bundle files accessed through the browser will still be served from memory.
This option also accepts a Function value, which can be used to filter which files are written to disk.
The function follows the same premise as Array#filter in which a return value of false will not write the file, and a return value of true will write the file to disk.