Package to enable customizing eVaka frontend(s) in forks without requiring merges or upstreaming all possible configurations.
NOTE: No new library dependencies can be installed as all the customization files are included in the main eVaka lib-customizations builds as is, and don't form a separate package/project.
NOTE 2: Currently employee-mobile-frontend
isn't included but can be added
later on.
Assuming directory layout like:
myfork/
├── frontend/
│ └── mytown/ # <- Your customizations, matches espoo/ contents
│ ├── citizen.tsx
│ └── ...
└── evaka/ (git submodule or similar)
└── frontend/
└── src/
└── lib-customizations/
├── espoo/ # <- Default customizations for Espoo
├── citizen.tsx # <- "root modules" that expose customizations
└── ...
-
Link your own directory to
./<your customization>
-
E.g. with symbolic or hard links:
# Running in evaka/frontend. # Assuming your customizations name is "mytown" and is placed in ../../frontend/mytown. ln -v -s $(readlink -f ../../frontend/mytown) src/lib-customizations/mytown
-
-
Run the build / dev server with
EVAKA_CUSTOMIZATIONS=<your customization>
, e.g.:# Build EVAKA_CUSTOMIZATIONS=mytown yarn build # Dev EVAKA_CUSTOMIZATIONS=mytown yarn dev
- Applies to all Webpack actions
-
Customizations can freely be split into multiple files but everything must be reachable by following the import chain from the main files:
Customizations generally consist of five basic parts:
-
Type definitions in
types.d.ts
-
Import & export in one of the "root" modules, e.g.
citizen.tsx
, using the@evaka/customizations/<module>
style of import paths (replaced by Webpack dynamically at build time) -
Actual implementation and export in
<customization>/<module>
, e.g.mytown/citizen.tsx
-
Default implementation in
espoo/<module>
, e.g.espoo/citizen.tsx
-
Import and usage of customized module in a project:
// Note the import path: nothing about "espoo" import { featureFlags } from 'lib-customizations/citizen' if (featureFlags.urgencyAttachmentsEnabled) { doStuff() }
NOTE: You might need to update frontend/.gitignore
to add some new files.
By default, everything should be exposed in the root modules and imported
by standard ES imports (import ... from ...
) but when importing something
handled only by Webpack (i.e. file loader, most commonly), use the
dynamically replaced path:
<link rel="shortcut icon" href="<%= require('@evaka/customizations/assets/favicon.ico') %>">