-
Notifications
You must be signed in to change notification settings - Fork 5
Damper
The damper is a small HTTP server which is useful for local development. It is installed as a binary and should be available as damper
in your terminal. If not, check that you have installed Commonplace via npm install -g commonplace
.
The damper, when run without any arguments, starts an HTTP server in the current directory. It should be run from the root of a project. By default, it will listen on localhost:8675
. This server will always serve src/index.html
unless the path can be found in src/
. I.e.: static files will be served, and all other URLs will return src/index.html
.
A basic file watcher will also be started, which will compile Stylus to CSS and Nunjucks templates to JS.
You can pass --port 1234
to specify a port. Hosts can be specified via --host 1.2.3.4
.
Two other sources of configuration can also be passed. If a "host"
or "port"
field is specified in the JSON file ~/.damperrc
(where ~
is the environment variable HOME
) for a key corresponding to the project directory. E.g.:
{
"/opt/my_proj": {"port": 9000},
"~/src/my_other_proj": {"host": "localhost.dev", "port": 9001}
}
The same information can also be specified in the src/.commonplace
manifest for a project:
{
"version": "0.2.0",
"port": 8676
}