@rspack/dev-server
Development server for rspack
Last updated 2 years ago by harpsealjs .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @rspack/dev-server 
SYNC missed versions from official npm registry.

@rspack/dev-server

npm version downloads node version license

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.mjs
export default {
  devServer: {
    // the configuration of the development server
    port: 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';
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. 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.

Current Tags

  • 1.0.0-alpha.5                                ...           alpha (2 years ago)
  • 2.0.0-beta.7                                ...           beta (8 months ago)
  • 0.7.6-canary-fd6c40d-20240918093542                                ...           canary (2 years ago)
  • 2.2.2                                ...           latest (a month ago)
  • 0.7.6-canary-f272bd8-20240625122346                                ...           nightly (2 years ago)
  • 2.0.0-rc.3                                ...           rc (7 months ago)
  • 0.0.0-canary-2d5264852-20230525090643                                ...           snapshot (4 years ago)

1115 Versions

Downloads
Total 1,920
Today 0
This Week 5
This Month 1,633
Last Day 0
Last Week 1,139
Last Month 151
Dependencies (9)
Dev Dependencies (38)

© 2010 - cnpmjs.org x YWFE | Home | YWFE