Skip to content

Commit

Permalink
Frontend build without dev dependencies (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
praseodym authored Jan 29, 2025
1 parent a1eaa97 commit 71704f1
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 154 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ on:
branches:
- main

env:
CARGO_TERM_COLOR: always
ASSET_DIR: ${{ github.workspace }}/frontend/dist
SQLX_OFFLINE: "true"

jobs:
backend:
name: Backend (${{ matrix.target.os }})
Expand All @@ -33,6 +28,11 @@ jobs:
defaults:
run:
working-directory: ./backend
env:
CARGO_TERM_COLOR: always
ASSET_DIR: ${{ github.workspace }}/frontend/dist
SQLX_OFFLINE: "true"
NODE_ENV: production
steps:
- uses: actions/checkout@v4
# Build frontend so that it can be included in the backend build
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ on:
schedule:
- cron: '0 12 * * 0'

env:
CARGO_TERM_COLOR: always
ASSET_DIR: ${{ github.workspace }}/frontend/dist
SQLX_OFFLINE: "true"

jobs:
build:
name: Build
Expand All @@ -30,6 +25,11 @@ jobs:
defaults:
run:
working-directory: ./backend
env:
CARGO_TERM_COLOR: always
ASSET_DIR: ${{ github.workspace }}/frontend/dist
SQLX_OFFLINE: "true"
NODE_ENV: production
steps:
- uses: actions/checkout@v4
- name: Setup Node
Expand Down
15 changes: 11 additions & 4 deletions frontend/app/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { createBrowserRouter, RouterProvider } from "react-router";

import { ApiProvider } from "@kiesraad/api";

// ignore in prod
import { startMockAPI } from "./msw-mock-api";
import { routes } from "./routes";

const rootDiv = document.getElementById("root");
Expand All @@ -29,8 +27,17 @@ function render() {
}

if (__API_MSW__) {
startMockAPI()
.then(render)
// import msw-mock-api here instead of at the top of the file,
// so that we only use MSW in development and don't need it in production
import("./msw-mock-api")
.then((mockAPI) =>
mockAPI
.startMockAPI()
.then(render)
.catch((e: unknown) => {
console.error(e);
}),
)
.catch((e: unknown) => {
console.error(e);
});
Expand Down
9 changes: 0 additions & 9 deletions frontend/app/types.d.ts

This file was deleted.

Loading

0 comments on commit 71704f1

Please sign in to comment.