Skip to content

Commit 0bacca1

Browse files
authored
Merge pull request #1565 from rust-lang/frontend-npm
Introduce frontend build system using npm, Parcel and TypeScript
2 parents 9a13211 + 94d1870 commit 0bacca1

32 files changed

+3582
-16
lines changed

.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
!/database
33
!/intern
44
!/site
5+
/site/frontend/node_modules
6+
/site/frontend/dist
57
!/collector
68
!/Cargo.toml
79
!/Cargo.lock

Dockerfile

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
FROM node:18 as frontend
2+
3+
COPY ./site ./site
4+
RUN cd site/frontend && npm ci
5+
RUN cd site/frontend && npm run check
6+
RUN cd site/frontend && npm run build
7+
18
FROM ubuntu:20.04 as build
29

310
RUN apt-get update -y && \
@@ -18,10 +25,11 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \
1825

1926
COPY ./Cargo.lock ./Cargo.lock
2027
COPY ./Cargo.toml ./Cargo.toml
21-
COPY ./site ./site
2228
COPY ./collector ./collector
2329
COPY ./database ./database
2430
COPY ./intern ./intern
31+
COPY ./site ./site
32+
COPY --from=frontend ./site/frontend/dist ./site/frontend/dist
2533

2634
RUN bash -c 'source $HOME/.cargo/env && cargo build --release -p site'
2735
RUN bash -c 'source $HOME/.cargo/env && cargo build --release --bin postgres-to-sqlite'

site/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/data
22
/target
3+
frontend/node_modules
4+
frontend/dist/**/

site/frontend/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# `rustc-perf` site frontend
2+
This directory contains code for the `rustc-perf` website frontend.
3+
4+
## Build instructions
5+
- Install dependencies
6+
```console
7+
$ npm install
8+
```
9+
- Development build - dynamically reloads after each change.
10+
```console
11+
$ npm run watch
12+
```
13+
- Production build - build optimized and minimized files.
14+
```console
15+
$ npm run build
16+
```
17+
18+
The files are packaged into the `dist` directory, from which they are embedded into the `rustc-perf`
19+
binary.
20+
21+
## Build system
22+
The frontend is built using the `Parcel` bundler. It generates several JavaScript files (one for each
23+
page in the perf.RLO website) into the `dist` directory.
24+
25+
It uses a custom backend for transpiling `TypeScript`, which transpiles for browsers defined in
26+
the `browserslist` attribute in `package.json`. It does not perform type-checking, that is why
27+
there is a dedicated `npm run check` action that uses `tsc`. It is performed on CI to find typ errors.
28+
The `tsconfig.json` file is only used by the type-checking action.

site/frontend/dist/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)