https://github.com/rstackjs/rspack-dev-server
Dev server for Rspack, modernized from webpack-dev-server.
https://github.com/rstackjs/rspack-dev-server
devserver rspack
Last synced: about 1 month ago
JSON representation
Dev server for Rspack, modernized from webpack-dev-server.
- Host: GitHub
- URL: https://github.com/rstackjs/rspack-dev-server
- Owner: rstackjs
- License: mit
- Created: 2024-09-23T08:33:14.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-04-22T09:37:52.000Z (about 1 month ago)
- Last Synced: 2026-04-22T11:34:12.044Z (about 1 month ago)
- Topics: devserver, rspack
- Language: JavaScript
- Homepage: https://rspack.rs/config/dev-server
- Size: 933 KB
- Stars: 38
- Watchers: 8
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @rspack/dev-server
Use Rspack with a development server that provides live reloading. This should be used for development only.
## Versions
- `2.x`: For Rspack v2, see [v1 -> v2](./docs/migrate-v1-to-v2.md) for migration guide.
- `1.x`: For Rspack v1, see [v1.x - README](https://github.com/rstackjs/rspack-dev-server/tree/v1.x#rspackdev-server) for usage guide.
## Installation
First of all, install `@rspack/dev-server` and `@rspack/core` by your favorite package manager:
```bash
# npm
$ npm install -D @rspack/dev-server @rspack/core
# yarn
$ yarn add -D @rspack/dev-server @rspack/core
# pnpm
$ pnpm add -D @rspack/dev-server @rspack/core
# bun
$ bun add -D @rspack/dev-server @rspack/core
```
## Usage
There are two recommended ways to use `@rspack/dev-server`:
### With the CLI
The easiest way to use it is with the [`@rspack/cli`](https://www.npmjs.com/package/@rspack/cli).
You can install it in your project by:
```bash
# npm
$ npm install -D @rspack/cli
# yarn
$ yarn add -D @rspack/cli
# pnpm
$ pnpm add -D @rspack/cli
# bun
$ bun add -D @rspack/cli
```
And then start the development server by:
```bash
# with rspack.config.js
$ rspack serve
# with custom config file
$ rspack serve -c ./your.config.js
```
> See [CLI](https://rspack.rs/api/cli) for more details.
While starting the development server, you can specify the configuration by the `devServer` field of your Rspack config file:
```js
// rspack.config.mjs
export default {
devServer: {
// the configuration of the development server
port: 8080,
},
};
```
> See [Rspack - devServer](https://rspack.rs/config/dev-server) for all configuration options.
### With the API
While it's recommended to run `@rspack/dev-server` via the CLI, you may also choose to start a server via the API.
```js
import { RspackDevServer } from '@rspack/dev-server';
import { rspack } from '@rspack/core';
import config from './rspack.config.mjs';
const compiler = rspack(config);
const devServerOptions = {
...config.devServer,
// override
port: 8888,
};
const server = new RspackDevServer(devServerOptions, compiler);
server.startCallback(() => {
console.log('Successfully started server on http://localhost:8888');
});
```
## Credits
This repository is forked from [webpack-dev-server](https://github.com/webpack/webpack-dev-server). It adapts the original implementation for the Rspack ecosystem, bridging behavioral differences with webpack while adding Rspack-specific capabilities.
> Thanks to the [webpack-dev-server](https://github.com/webpack/webpack-dev-server) maintainers and its original creator, [@sokra](https://github.com/sokra).
## License
[MIT licensed](https://github.com/rstackjs/rspack-dev-server/blob/main/LICENSE).