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.
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
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
--port Port to use (defaults to 8080)
--keys Comma separated list of keys to pick vom
process.env and inject into
.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.