Skip to content

Commit 90be24c

Browse files
committed
Update README
1 parent 21acf36 commit 90be24c

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

README.md

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,70 @@
1-
# WIP: rules_devserver: Bazel rule for running a web development server
1+
# rules_devserver: Web Development Server Bazel Rule
22

33
This repository contains a Bazel rule for running a development server. It is
44
intended to be used for local development, and is not intended for production
55
use.
66

7-
This is WIP. It is not yet ready for use.
7+
## Features
8+
9+
* Live-reload via `ibazel` and a custom live-reload script.
10+
* Custom routes for any dependency in the BUILD rule's `data` attribute.
11+
12+
## Pre-requisites
13+
14+
* Bazel 6.0.0 or higher
15+
* ibazel for live-reload
16+
17+
## Setup
18+
19+
### Workspace
20+
21+
```
22+
workspace(name = "test_rules_devserver")
23+
24+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
25+
http_archive(
26+
name = "rules_devserver",
27+
strip_prefix = "rules_devserver-0.1.0",
28+
urls = ["https://github.com/ryanmcdermott/rules_devserver/archive/refs/tags/0.1.0.tar.gz"],
29+
)
30+
```
31+
32+
### Example BUILD file
33+
34+
```
35+
load("@rules_devserver//devserver:defs.bzl", "devserver")
36+
37+
filegroup(
38+
name = "index",
39+
srcs = ["index.html"],
40+
visibility = ["//visibility:public"]
41+
)
42+
43+
filegroup(
44+
name = "bundle"
45+
srcs = ["bundle.js"],
46+
visibility = ["//visibility:public"]
47+
)
48+
49+
devserver(
50+
name = "serve",
51+
port = 8081,
52+
workspace_name = "test_rules_devserver",
53+
static_files = {
54+
"/": [":index", "index.html"],
55+
"/scripts/bundle.js": [":bundle", "bundle.js"]
56+
},
57+
data = [":index", ":bundle"]
58+
)
59+
```
60+
61+
The `static_files` attribute is a dictionary of routes to files. The key is the route and the value is a tuple
62+
of the [filegroup target, file name]. All targets in the `static_files` attribute must also be in the `data` attribute.
63+
64+
## Usage of Example BUILD file
65+
66+
```
67+
ibazel run //:serve
68+
```
69+
70+
Whenever a file in the `data` attribute is changed, the server will be live-reloaded.

0 commit comments

Comments
 (0)