Skip to content
/ serve Public
forked from tynanbe/wonton

πŸ› Ultralight http server with live reload. [CLI + API]

License

Notifications You must be signed in to change notification settings

btwiuse/serve

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Serve πŸ›

Ultralight http server with live reload.
CLI + API


Simple CLI and API

With live reload

Light and modern

With secure protocol

With SPA support

No dependencies


One command

npm init serve

Or one function

import serve from 'create-serve';

serve.start();

To start πŸ›


CLI

By default, it serves public if the folder exists, otherwise root /.
Or you can specify a different folder.

npm init serve [folder]

API

import serve from 'create-serve';

serve.start({
    host: 'localhost',
    port: 7000,
    root: '.',
    live: true,
    fallback: 'index.html',
    isHttps: true,
    tlsOptions: {
      key: 'absolute path to private key',
      cert: 'absolute path to cert',
    },
});

Live reload

serve.update();

Use any file watcher


Chokidar

import serve from 'create-serve';
import chokidar from 'chokidar';

serve.start();

chokidar.watch('.').on('change', () => {
    serve.update();
});

esbuild

Use the official wrapper for esbuild's watch Β  β†’ Β  esbuild-serve


Log

Import the util functions to log updates with colours.

import serve, { error, log } from 'create-serve';

serve.update();

hasError
    ? error('Γ— Failed') // Red
    : log('βœ“ Updated'); // Green



Native Web

About

πŸ› Ultralight http server with live reload. [CLI + API]

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 91.5%
  • HTML 8.5%