Miss any of our Open RFC calls?Watch the recordings here! »

@grapes-agency/simple-spa-server

1.1.4 • Public • Published

Simple SPA Server:

simple-spa-server is our standard static file server to serve SPA assets (index.html, js/css bundles etc.).

It does not do much more than just serve the files and use mime-types to set a Content-Type header. For production deployment we would expect a fully configured reverse proxy in front.

What it can do in addition to that is inject env variables into your index.html by placing a <script> tag in the HTML head which will set a process.env object on the window. These variables can be picked from a provided .env file (using dotenv) or from the server side process.env or both.

Installing:

Installation via npm:

npm install @grapes-agency/simple-spa-server

This will install into your local node_modules and make the command simple-spa-server available in node_modules/bin (can be used in npm scripts that way).

To make it available globally:

npm install -g @grapes-agency/simple-spa-server

Usage:

simple-spa-server <path> [options]

<path> is required and should point to the folder where the index.html for your SPA is located.

Application should be available under http://localhost:8080

Available Options:

-p or --port Port to use (defaults to 8080)

-k or --keys Comma separated list of keys to pick vom process.env and inject into index.html. If .env file is present this option will pick from these as well. If omitted and .env is present, all keys from .env will be injected.

Install

npm i @grapes-agency/[email protected]

Version

1.1.4

License

MIT

Unpacked Size

38.1 kB

Total Files

25

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar