Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ First of all, install `@rspack/dev-server` and `@rspack/core` by your favorite p

```bash
# npm
$ npm install @rspack/dev-server @rspack/core --save-dev
$ npm install -D @rspack/dev-server @rspack/core

# yarn
$ yarn add @rspack/dev-server @rspack/core --dev
$ yarn add -D @rspack/dev-server @rspack/core

# pnpm
$ pnpm add @rspack/dev-server @rspack/core --save-dev
$ pnpm add -D @rspack/dev-server @rspack/core

# bun
$ bun add @rspack/dev-server @rspack/core -D
$ bun add -D @rspack/dev-server @rspack/core
```

## Usage
Expand All @@ -43,16 +43,16 @@ You can install it in your project by:

```bash
# npm
$ npm install @rspack/cli --save-dev
$ npm install -D @rspack/cli

# yarn
$ yarn add @rspack/cli --dev
$ yarn add -D @rspack/cli

# pnpm
$ pnpm add @rspack/cli --save-dev
$ pnpm add -D @rspack/cli

# bun
$ bun add @rspack/cli -D
$ bun add -D @rspack/cli
```

And then start the development server by:
Expand All @@ -72,28 +72,27 @@ While starting the development server, you can specify the configuration by the
```js
// rspack.config.mjs
export default {
// ...
devServer: {
// the configuration of the development server
port: 8080,
},
};
```

> See [DevServer](https://rspack.rs/config/dev-server) for all configuration options.
> 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 rspackConfig from './rspack.config.mjs';
import { rspack } from '@rspack/core';
import config from './rspack.config.mjs';

const compiler = rspack(rspackConfig);
const compiler = rspack(config);
const devServerOptions = {
...rspackConfig.devServer,
...config.devServer,
// override
port: 8888,
};
Expand All @@ -105,8 +104,6 @@ server.startCallback(() => {
});
```

> Cause `@rspack/dev-server` is based on `webpack-dev-server@5`, you can see the [webpack-dev-server API](https://webpack.js.org/api/webpack-dev-server/) for more methods of the server instance.

## Credits

This plugin is forked from [webpack-dev-server](https://github.com/webpack/webpack-dev-server), and is used to smooth out some differences between rspack and webpack, while also providing rspack-specific new features.
Expand Down