1.0.8 • Published 5 years ago

@transcend-io/spa-static-server v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

spa-static-server

A simple javascript server to host a production SPA build, or an auto-reloading development build, using environment variables only.

Features

  • Builds a simple docker image useful for running static builds from a docker compose yml file hosted at transcendio/spa-static-server.
  • Host with HTTPS
  • Runs a static build redirecting 404s to index.html
  • Has the ability to download builds from
  • Auto-reloads on build change in NODE_ENV=development
  • Fetches GraphQL fragment types and writes them to file
  • Proxies all requests matching PROXY_ROUTE to the backend

Setup

  1. Clone:

    git clone https://github.com/transcend-io/spa-static-server.git
  2. Build the docker image

    npm run build
  3. Install locally

    npm i

Usage as Docker Image

An example of using this docker file can be found in examples/example.yml.

  1. Modify the file to point to files on your local machine
  2. Run npm run build to build the image
  3. Docker compose the example examples/docker-compose -f example.yml up

Usage as Cli

The server can be installed with npm and used as at the command line.

npm i transcend-io/spa-static-server
BUILD_ENV_PATH=./env tr-server

Environment Variables

NameCommentDefaultRequired
BACKEND_URLThe URL of the backend serverNAREQUIRED
FRONTEND_URLThe URL to host the frontend server onNAREQUIRED
PROXY_ROUTEProxy all requests made by the frontend to the BACKEND_URL starting with this path/backendREQUIRED
NODE_ENVNode environmentproductionOPTIONAL
WEBPACK_PATHWebpack configuration pathNAREQUIRED if NODE_ENV!=production
SSL_CERTThe location of the SSL certificate/ssl/certificate.pemOPTIONAL
SSL_KEYThe location of the SSL key/ssl/private.keyOPTIONAL
BUILD_PATHThe location to keep the build/buildOPTIONAL
S3_BUCKETThe location of the S3 bucket holding the buildNAOPTIONAL
AWS_ACCESS_KEY_IDThe AWS access key needed to download from the bucketNAREQUIRED if S3_BUCKET provided
AWS_SECRET_ACCESS_KEYThe AWS secret key needed to download from the bucketNAREQUIRED if S3_BUCKET provided
WRITE_FRAGMENT_PATHProvide the path to where GraphQL fragments be writtenNAOPTIONAL
FRAGMENTS_ROUTEThe GraphQL route to get fragments from on BACKEND_URL/graphqlOPTIONAL
BUILD_ENV_PATHA .env file to read environment variables fromNAOPTIONAL
1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago