Skip to content

Commit 0b32480

Browse files
authored
Merge pull request #229 from grafana/docs/add-frontend-dev-instructions
docs: Add instructions for frontend development
2 parents 052d363 + 421b6bb commit 0b32480

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

CONTRIBUTING.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,79 @@ All the tools used for development are free and open-source, so you can install
8383

8484
The version numbers of tools used in GitHub workflows are defined as [repository variables](https://github.com/grafana/xk6-dashboard/settings/variables/actions). The version numbers of tools used in the *Development Containers* are only defined in the `.devcontainer/devcontainer.json` file. The version numbers should be updated carefully to be consistent.
8585

86+
## Frontend Development
87+
88+
If you want to work on the frontend components without using devcontainers, you can run the frontend development servers directly. The project uses [Lerna](https://lerna.js.org/) to manage multiple packages in the `dashboard/assets` directory.
89+
90+
### Prerequisites
91+
92+
- [Node.js](https://nodejs.org/) (version 18 or higher)
93+
- [Yarn](https://yarnpkg.com/) package manager
94+
- [Go](https://golang.org/) (for backend server)
95+
96+
### Running the Frontend
97+
98+
1. **Install dependencies** (only needed once):
99+
```bash
100+
cd dashboard/assets
101+
yarn install
102+
```
103+
104+
2. **Start the development servers**:
105+
106+
**Option 1: Use Lerna to run dev scripts across all packages**
107+
```bash
108+
# From the dashboard/assets directory
109+
npx lerna run dev --parallel
110+
```
111+
112+
This will start development servers for all packages that have a `dev` script (UI, Report, Model, and View packages).
113+
114+
**Option 2: Run individual packages**
115+
```bash
116+
# Start the UI development server (typically on http://localhost:5173)
117+
cd packages/ui
118+
yarn dev
119+
120+
# In another terminal, start the Report development server (typically on http://localhost:5174)
121+
cd packages/report
122+
yarn dev
123+
```
124+
125+
### Running the Backend Server
126+
127+
To test the frontend with real data, you can run the backend server using the provided sample dataset:
128+
129+
**Option 1: Build and run the CLI tool**:
130+
```bash
131+
# Build k6-web-dashboard
132+
go build -o k6-web-dashboard ./cmd/k6-web-dashboard
133+
# Replay the sample test data
134+
./k6-web-dashboard replay dashboard/testdata/result.ndjson.gz
135+
```
136+
137+
This will start the backend server (typically on http://localhost:8080) and serve the dashboard with the sample test data.
138+
139+
**Option 2: Use Go run directly**:
140+
```bash
141+
go run ./cmd/k6-web-dashboard replay dashboard/testdata/result.ndjson.gz
142+
```
143+
144+
### Development Workflow
145+
146+
1. Start the frontend development servers
147+
2. Start the backend server with sample data
148+
3. Make changes to the frontend code - they will automatically reload
149+
4. The frontend will connect to the backend server automatically to display real metrics data
150+
151+
### Available Frontend Packages
152+
153+
- **UI Package** (`packages/ui`): Main dashboard interface with charts, tables, and interactive components
154+
- **Report Package** (`packages/report`): Static report generation for sharing results
155+
- **Model Package** (`packages/model`): TypeScript types and data models
156+
- **Config Package** (`packages/config`): Configuration management
157+
- **View Package** (`packages/view`): Chart rendering utilities
158+
86159
## Tasks
87160

88161
The usual contributor tasks can be performed using GNU make. The `Makefile` defines a target for each task. To execute a task, the name of the task must be specified as an argument to the make command.

0 commit comments

Comments
 (0)