Skip to content

Repository files navigation

@rspack/dev-server

npm versiondownloadsnode versionlicense

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 for migration guide.
  • 1.x: For Rspack v1, see v1.x - README for usage guide.

Installation

First of all, install @rspack/dev-server and @rspack/core by your favorite package manager:

# 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.

You can install it in your project by:

# 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:

# with rspack.config.js
$ rspack serve
# with custom config file
$ rspack serve -c ./your.config.js

See CLI for more details.

While starting the development server, you can specify the configuration by the devServer field of your Rspack config file:

// rspack.config.mjsexportdefault{devServer: {// the configuration of the development serverport: 8080,},};

See Rspack - devServer 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.

import{RspackDevServer}from'@rspack/dev-server';import{rspack}from'@rspack/core';importconfigfrom'./rspack.config.mjs';constcompiler=rspack(config);constdevServerOptions={
...config.devServer,// overrideport: 8888,};constserver=newRspackDevServer(devServerOptions,compiler);server.startCallback(()=>{console.log('Successfully started server on http://localhost:8888');});

Credits

This repository is forked from 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 maintainers and its original creator, @sokra.

License

MIT licensed.

About

Dev server for Rspack, modernized from webpack-dev-server.

Topics

Resources

Stars

42 stars

Watchers

9 watching

Forks

Releases

Used by

Contributors

Languages