npm.io
0.19.0 • Published 3d ago

@chialab/rna-dev-server

Licence
MIT
Version
0.19.0
Deps
5
Size
51 kB
Vulns
0
Weekly
0
Stars
183

RNA Dev Server

A webapp server based on Web Dev Server.

RNA cli development is deprecated and discontinued. It's recommended to use RNA plugins directly in your projects using vite, esbuild, or other supported tools.

NPM

Install

npm i @chialab/rna-dev-server -D
yarn add @chialab/rna-dev-server -D
pnpm add @chialab/rna-dev-server -D

Usage

Start a web dev server that transforms ESM imports for node resolution on demand. It also uses esbuild to compile non standard JavaScript syntax.

Via import
import { serve } from '@chialab/rna';

/**
 * @see https://modern-web.dev/docs/dev-server/cli-and-configuration/
 */
await serve({
    // rootDir: '.',
});
Via cli
rna serve [options] [root]

Options:
  -P, --port <number>  server port number
  -C, --config <path>  the rna config file
  -h, --help           display help for command

Samples

rna serve
rna serve public --port 3000
As middleware
import { createServer } from 'http';
import { createDevServer, loadDevServerConfig } from '@chialab/rna-dev-server';
import express from 'express';

const app = express();
const server = createServer(app);
const config = await loadDevServerConfig({
    rootDir: 'src',
});
const devServer = await createDevServer(config);
await devServer.start(server);
app.use(devServer.callback());
Integrations
  • RNA CakePHP: a view helper to inject scripts and css with livereload.

License

RNA Dev Server is released under the MIT license.

Keywords