npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@transcend-io/spa-static-server

v1.0.8

Published

A docker image that will run a static build of a SPA, redirecting 404 to index.html

Downloads

14

Readme

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

| Name | Comment | Default | Required | | --- | ----------- | ----------- |-----------| | BACKEND_URL | The URL of the backend server | NA | REQUIRED | | FRONTEND_URL | The URL to host the frontend server on | NA | REQUIRED | | PROXY_ROUTE | Proxy all requests made by the frontend to the BACKEND_URL starting with this path | /backend | REQUIRED | | NODE_ENV | Node environment | production | OPTIONAL | | WEBPACK_PATH | Webpack configuration path | NA | REQUIRED if NODE_ENV!=production | | SSL_CERT | The location of the SSL certificate | /ssl/certificate.pem | OPTIONAL | | SSL_KEY | The location of the SSL key | /ssl/private.key | OPTIONAL | | BUILD_PATH | The location to keep the build | /build | OPTIONAL | | S3_BUCKET | The location of the S3 bucket holding the build | NA | OPTIONAL | | AWS_ACCESS_KEY_ID | The AWS access key needed to download from the bucket | NA | REQUIRED if S3_BUCKET provided | | AWS_SECRET_ACCESS_KEY | The AWS secret key needed to download from the bucket | NA | REQUIRED if S3_BUCKET provided | | WRITE_FRAGMENT_PATH | Provide the path to where GraphQL fragments be written | NA | OPTIONAL | | FRAGMENTS_ROUTE | The GraphQL route to get fragments from on BACKEND_URL | /graphql | OPTIONAL | | BUILD_ENV_PATH | A .env file to read environment variables from | NA | OPTIONAL |