Catalog npm
Back to packageRELEASE DETAILS

1.1.0

npm

3dub

www dev server with livereload

certdevh2http2httpslivereloadpfxsslwatchwebwww
Published10 Jan 2018
Direct dependencies14
Transitive dependenciesNot calculated

README

Current package documentation

3dub

Greenkeeper badge

www dev server with livereload and file watching for developing Single Page Applications.

Features

  1. Serve static files
  2. File watching of the static files
  3. Livereload when watched files change
    • Starts its own livereload server
    • Automatically inject livereload into your application
  4. Https and Http2 support
  5. Auto generation of self signed certs
  6. Proxy settings with socket support
  7. Built on top of battle tested tools such as Express, chokidar, tiny-lr, and more.

Examples

Hello world

This setup will quickly walk you through starting up a server with ZERO configuration (all default settings). Serve up static assets, monitor them and when they change, livereload will refresh the browser where you are viewing your application.

install 3dub globally

$ npm install 3dub -g

create public folder

By default, 3dub serves up static assets from a directory called public relative where 3dub starts from. So let's go ahead and create one if one does not already exist. All your code goes in there.

$ mkdir public

start 3dub

$ 3dub

view in the browser

$ open http://localhost:3000

Custom port via configuration file

Adding a configuration for 3dub is a way to customize default settings. Generally, you will create configuration files wherever you expect to start 3dub from.

configure 3dub

Create a file called .3dub.js and configure the server port.

module.exports = {
  "port": 4545
};

start 3dub

$ 3dub

CLI examples

All options available for 3dub are for both the CLI and configuration files. Configuration files just makes some situations easier to work with as in the case of defining complex option object when defining middlewares.

start 3dub with custom port

$ 3dub --port 4545

3dub with root directory

$ 3dub --root dest

3dub with http2 and custom port

$ 3dub --mode http2 --port 8443

Configuration

3dub allows you to define a configuration in your project's directory. You can also specify a default configuration file in your HOME directory. If you specify both, the your local project's definition will be mixed in with the settings defined in HOME.

The default name of your configuration is .3dub.json for JSON and .3dub.js for JavaScript. You can alternatively create a .3dub directory with an index.js that contains your settings.

Options (Configuration file and CLI)

CLI only supports subarg notation when working complex object.

  • config (string) Configuration file name to load. By default it will load .3dub.json and .3dub.js files or .3dub directory with an index.js file in it. CLI only

  • log (boolean) flag to disable logging of noisy messages. Defaults to true.

  • port (number) port to for the server to listen on for incoming requests. Defaults to 3000.

  • root (string) path to serve files from. Defaults to public.

  • history (string | object) to configure the history middleware for managing your SPA. For details on the settings, please see here. Defaults to index.html.

  • livereload (number | object | boolean) When false, livereload is disabled. When its a number, then livereload client and server use that as the port number. When it is an object, settings are those used by tiny-lr. If you want to specify different settings for the livereload client and livereload server, then you can define a server and a client object with the corresponding options. Default value is the port number 35729.

  • watch (string[] | object | boolean) When false, file watching is disabled. When string or array of strings, you sepcify the files and directories to be monitored for changes; globs are supported. If options is an object, then they are forwarded to chokidar. watch is only enabled when livereload is enabled. Defaults to the root directory.

  • proxies (array<{source, target}>) Array of objects with a source property for the local url path and a target to the remote url path we are mapping to.

  • middlewares (array<string | object | array> | object) Option to define middlewares to be loaded. You can specify an array of middleware module names, you can also specify an object whose keys are the names of middleware modules and the values are the corresponding options for them. You can also specify middlewares using subarg notation, which is an array where the first item is the middleware module name and the second item are the options for it; e.g. ["middleware-module", options].

  • spdy (object) configure the http2 handler. Please take a look at the spdy module for details on the valid options.

  • mode (string) configure what protocol to run. E.g. http, https, or http2. For https and http2 mode, you must provide the pair cert and key or pfx and passphrase. If you do not provide either, a self signed certificate will be automatically generated for you.

  • cert (string) When using https, the cert option is for specifying the file path to the certificate file to be used by the server.

  • key (string) When using https, the key option is for specifying the file path to the private key file to be used by the server.

  • pfx (string) When using https, the pfx option is for specifying the file path for the pfx file to be used by the server.

  • passphrase (string) When using https, the passphrase option is required for opening the pfx file that will be used by the server.

Self signed certificates

When running 3dub in https or http2 mode, you have the option to specify your own certificate. If one isn't provided, then 3dub will create its own self signed certificate and will log a warning. A self signed certificate is automatically created to make it really easy to get a dev server up and running. And... The self signed cerficate is not written to disk.

Installation

Install via npm as a dev dependency, and configure an npm script to start the server. This is my preferred approach as it allows you to define the version of 3dub on a per project basis and also removes the need to install 3dub globally.

$ npm install 3dub --save-dev

Install globally so that you can start 3dub from anywhere via CLI.

$ npm install 3dub -g

Requirements

For http2 to work as expected, nodejs 4.8.0 and above is required. This is because ALPN was added in that version of node which is required by browsers like Chrome to properly negotiate the protocol.

https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V4.md#2017-02-21-version-480-argon-lts-mylesborins

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 14

Native requirements
14 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
belty
Environment
{
  "local_name": "belty",
  "alias": false,
  "peer_metadata": null
}
^5.1.0runtime
body-parser
Environment
{
  "local_name": "body-parser",
  "alias": false,
  "peer_metadata": null
}
^1.17.2runtime
camelcase-keys
Environment
{
  "local_name": "camelcase-keys",
  "alias": false,
  "peer_metadata": null
}
^4.1.0runtime
chokidar
Environment
{
  "local_name": "chokidar",
  "alias": false,
  "peer_metadata": null
}
^2.0.0runtime
connect-history-api-fallback
Environment
{
  "local_name": "connect-history-api-fallback",
  "alias": false,
  "peer_metadata": null
}
^1.3.0runtime
connect-livereload
Environment
{
  "local_name": "connect-livereload",
  "alias": false,
  "peer_metadata": null
}
^0.6.0runtime
dis-isa
Environment
{
  "local_name": "dis-isa",
  "alias": false,
  "peer_metadata": null
}
^1.3.0runtime
express
Environment
{
  "local_name": "express",
  "alias": false,
  "peer_metadata": null
}
^4.15.4runtime
node-proxy-middleware
Environment
{
  "local_name": "node-proxy-middleware",
  "alias": false,
  "peer_metadata": null
}
^0.15.2runtime
resolve
Environment
{
  "local_name": "resolve",
  "alias": false,
  "peer_metadata": null
}
^1.4.0runtime
selfsigned
Environment
{
  "local_name": "selfsigned",
  "alias": false,
  "peer_metadata": null
}
^1.10.1runtime
spdy
Environment
{
  "local_name": "spdy",
  "alias": false,
  "peer_metadata": null
}
^3.4.7runtime
subarg
Environment
{
  "local_name": "subarg",
  "alias": false,
  "peer_metadata": null
}
^1.0.0runtime
tiny-lr
Environment
{
  "local_name": "tiny-lr",
  "alias": false,
  "peer_metadata": null
}
^1.0.5runtime

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "b59750f89071c870b3053d25591098a1079cc33f",
  "tarball": "https://registry.npmjs.org/3dub/-/3dub-1.1.0.tgz",
  "integrity": "sha512-rScqCIlMDy5lsqJcttxqBW1zwRzrVgn/tXu6aWEgwChe3Y7N0O8rr6CaN2eh4sDFvh6m60WVXefGP42PTGieKg==",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEUCIAJ/F2s6XX2AFEiVf5jFw3XPbu92EOb0VkugzERXj1hVAiEA0I2EUABKypXD8gvcArdzSZMzREuqNBHXPO0HKAUOUaU="
    }
  ]
}

Repository

PENDING
miguelcastillo/3dub

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:41 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:dc09b95c714fa183adf1f5e3dc5f652e2b8a0f22d0d58c6cd0af318496186e2e

Other collected versions

1.0.110 Jan1.0.020 Dec0.5.015 Sept0.4.014 Sept0.3.014 Sept0.2.013 SeptView all collected versions →