node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

buddy-server

NPM Version

buddy-server

A simple development fileserver, with LiveReload support, for the buddy build tool.

WARNING: default fileserving is very permissive! This is inherently insecure, and therefore only recommended for local development.

When working with the LiveReload feature, it is recommended to install the LiveReload Chrome extension, or include the following in your html source to initiate the connection:

<script src="http://localhost:35729/livereload.js"></script>

Usage

{
  "devDependencies": {
    "buddy": "6.13.0",
    "buddy-server": "3.0.0"
  },
  "buddy": {
    "server": {
      "port": 8000,
      "directory": "www"
    }
  }
$ buddy watch --serve --reload

Specify multiple directories:

"buddy"{
  "server": {
    "port": 8000,
    "directory": ["www", "assets"]
  }
}

Configure headers to pass to the default static file server:

"buddy"{
  "server": {
    "port": 8000,
    "directory": "www",
    "headers": {
      "x-foo": "foo"
    }
  }
}

Specify an alternative root url from which to serve source maps:

"buddy"{
  "server": {
    "port": 8000,
    "directory": "www",
    "sourceroot": "https://raw.githubusercontent.com/user/repo/master/"
  }
}

Custom application server

To use a custom application server instead of the default, specify a file path to your server:

"buddy"{
  "server": {
    "port": 8000,
    "file": "./index.js"
  }
}

Configure environment variables with env:

"buddy"{
  "server": {
    "port": 8000,
    "file": "./index.js",
    "env": {
      "DEBUG": "*"
    }
  }
}

Configure flags to pass to the Node process running your server:

"buddy"{
  "server": {
    "port": 8000,
    "file": "./index.js",
    "flags": ['--inspect']
  }
}

NOTE The current port number will be exposed as process.env.PORT.