https://github.com/roxiness/spassr
https://github.com/roxiness/spassr
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/roxiness/spassr
- Owner: roxiness
- Created: 2020-04-06T13:17:06.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-07T11:39:14.000Z (almost 5 years ago)
- Last Synced: 2025-04-21T10:54:25.574Z (about 1 year ago)
- Language: JavaScript
- Size: 254 KB
- Stars: 32
- Watchers: 4
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

### Small Express server with SSR
#### Usage example
$ npx spassr --assets-dir dist --entrypoint dist/index.html --script dist/build/bundle.js --ssr
#### Configuration
Spassr can be configured through `CLI`, `package.json`, `spassr.config.js` and `.env`.
Environment variables are converted from snake_case to camelCase, so `SPASSR_assets_dir = dist` becomes `{... assetsDir: 'dist'}`
For configuration options, refer to the API below.
* * *
### API
##### Table of Contents
- [spassr](#spassr)
- [Parameters](#parameters)
- [Config](#config)
- [Properties](#properties)
- [Eval](#eval)
- [Parameters](#parameters-1)
- [config](#config-1)
#### spassr
##### Parameters
- `options` **Partial<config.Config>** \*
#### Config
Type: [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
##### Properties
- `assetsDir` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)** folders with static content to be served.
- `entrypoint` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** HTML template, eg. assets/index.html.
- `script` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** path to app, eg. build/bundle.js.
- `port` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number))** port to serve on.
- `ssr` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** enable SSR for routes not resolved in assetsDir.
- `silent` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** quiet console.log.
- `middleware` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function)** function to customize SPA server (_Not available in CLI_).
- `ssrOptions` **Partial<tossr.Config>** options to pass to ssr.
#### Eval
Called before/after the app script is evaluated
Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
##### Parameters
- `dom` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The DOM object
#### config
Type: [Config](#config)
---