Skip to content

A dev server for web development

License

Notifications You must be signed in to change notification settings

tmichel/devserver

Repository files navigation

devserver

devserver is a reverse proxy and build server for web applications.

Features

  • Rebuild and restart when you hit Enter.
  • Live reload on restarts and file changes
  • Hot-reloading for CSS files: CSS files used via a <link> tag are updated in place without reloading the page.

Installation

go install github.com/tmichel/devserver@latest

Under the hood devserver uses fswatch for monitoring file changes.

To install fswatch on macOS run the following

brew install fswatch

Detailed install instructions can be found in fswatch's README.

Usage

For details run

devserver -h

Example

cd /path/to/your/project
devserver \
    -build-cmd "go build -o bin/my-app"  \
    -server-cmd "bin/my-app -addr {}" \
    -web-root $PWD/files
# visit http://localhost:8080

-build-cmd defines the build command. Defaults to make. Set it to an empty string to skip the build.

-server-cmd defines the command for starting the server. Use {} as a placeholder for the host and port. It is passed in the format of host:port.

-web-root sets the root directory for files served by your web server. It is used to compute absolute URLs for files. For example when -web-root /path/to/web-root is set the file located at /path/to/web-root/css/style.css will be reported as /css/style.css. This allows hot reloading CSS files.

Example: using go run

Sometimes building and running are not separate. For example when using go run to build and execute your program there is no separate build step. In these situations you can specify -build-cmd="" to skip the build.

cd /path/to/your/project
devserver \
    -build-cmd "" \
    -server-cmd "go run . -addr {}"  \
    -web-root $PWD/files
# visit http://localhost:8080

About

A dev server for web development

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages