This project uses Vite as the build tool and Elm as the main language.
You must have yarn installed to develop or build.
To run the frontend against a local Phoenix backend (instead of staging):
Prerequisites: the backend repo must be cloned, migrated, and seeded — see its README.
Step 1 — install dependencies:
yarn install
Step 2 — start the backend (in the backend repo):
mix phx.server
The backend listens on http://localhost:4000.
Step 3 — start the frontend:
USE_SUBDOMAIN=false yarn start
The USE_SUBDOMAIN=false flag switches auth storage from cookies (subdomain-scoped) to localStorage and enables public/env-config.js, which points the app at localhost:4000.
Open http://localhost:3000 in your browser.
Modern browsers resolve *.localhost to 127.0.0.1 without any /etc/hosts changes. You can access the app at http://cambiatus.staging.localhost:3000 and the frontend will detect the community slug (cambiatus) and environment (staging) from the subdomain automatically. Auth tokens are stored as cookies scoped to .staging.localhost.
yarn install
yarn start
This connects to https://staging.cambiatus.io by default (no local backend needed).
To update the GraphQL Elm files, run:
yarn generate-graphql
We check JS with StandardJS and Elm with elm-review
before the git push using husky. You can also run yarn standard and yarn review
at any moment to make sure your code is passing the linters.
You can also use elm-analyse to get even more insights about the code.
This package is not included in the repo, you should install it manually:
yarn global add elm-analyse
elm-analyse # view analyse result in terminal
elm-analyse -p 3001 -s # show extended analyse in the browser on `localhost:3001`yarn install
yarn build
The app has a layered configuration stack:
public/env-config.js— runtime config loaded via<script>tag before the app starts. Setswindow._env_with API URLs, feature flags, and keys. In local dev this file points tolocalhost:4000. On deployed environments (staging, demo, production) this file is replaced server-side with environment-specific values.src/scripts/config.js— build-time defaults. Whenwindow._env_is present (i.e.env-config.jsloaded), these are overridden by it. When absent (noenv-config.js), falls back to hardcoded staging URLs.src/elm/Flags.elm— Elm entrypoint for configuration. Receives the resolved config as flags fromsrc/index.jsand decodes it into typed values.
The app uses Vite 2.9 with vite-plugin-elm for Elm compilation. Key notes:
@sentry/browseris stubbed to a no-op in development (src/scripts/sentry-stub.js) to avoid avar globalconflict in its pre-bundled output. Sentry is only initialised in production builds.- Node.js polyfills (
crypto,buffer,stream,util,process) are injected viavite-plugin-node-polyfillsforeosjscompatibility. - The legacy Webpack setup is still present under
scripts/andconfig/and can be used viayarn start:webpackif needed.