@grapes-agency/simple-spa-server
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • 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.

Package Sidebar

Install

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

Weekly Downloads

11

Version

1.3.1

License

MIT

Unpacked Size

41.6 kB

Total Files

25

Last publish

Collaborators

  • grapes-gmbh
  • jguse
  • cpoyatos
  • tsollbach
  • torsten4385
  • tim.fullert