Something like:
- Install NodeJS
cd frontend
npm install
npm start
(configure API root in src/config/dev.js
)
If you are not working on the front-end and just need it to build for distribution/deployment, run npm install --production instead
Build distribution version of app (starting at repo root):
cd frontend
npm run dist
cd ../public
Serve built front-end:
python -mSimpleHTTPServer <port, defaults to 8000>
# Get code
$ go get -u github.com/HelloSundayMorning/hsm-acem-survey-app
# Set environment variables
$ cp config/.envrc.example config/.envrc
$ source config/.envrc
# Setup postgres database
$ postgres=# CREATE USER acem;
$ postgres=# CREATE DATABASE acem_dev OWNER acem;
# Update dependencies and run migrations
$ go get -d -t ./...
$ go run db/reset.go
$ go run db/seeds.go
# Setup environment
...
# Run Application
$ go run main.go
Assets are shared between JS frontend and Go backend templates. Assets
are created via Webpack and output to public/assets
. Any files in
frontend/public
are copied directly to public/
.
Generated assets are listed in public/assets/manifest.json
(generated when frontend is built with env=dist
).
Go backend reads this file and provides a template function asset
that will map the input asset filename to the generated asset.
In development (or rather, if the environment variable
SERVE_STATIC_ASSETS
is not blank, the Go backend will serve assets
from http://.../assets
directly, mapping to public/assets
.
In production, assets should be served by Nginx directly from the
public directory (via tryfiles
).