Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roxiness/spank
Slap the pages out of a SPA
https://github.com/roxiness/spank
export html spa ssr static static-export
Last synced: 3 days ago
JSON representation
Slap the pages out of a SPA
- Host: GitHub
- URL: https://github.com/roxiness/spank
- Owner: roxiness
- Created: 2020-09-21T16:15:33.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-21T07:22:33.000Z (about 1 year ago)
- Last Synced: 2024-04-24T23:48:38.206Z (7 months ago)
- Topics: export, html, spa, ssr, static, static-export
- Language: JavaScript
- Homepage:
- Size: 928 KB
- Stars: 51
- Watchers: 5
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
## Static Site Generator (SSG)
#### Exports HTML pages from your SPA### Usage
```javascript
//spank.config.js
module.exports = {
sitemap: 'path/to/a-list-of-urls.json',
template: 'dist/__index.html',
script: 'dist/main.js',
outputDir: 'dist'
}
```open your terminal and type
```
npx spank
```###### Note
spank can also be used without a config. Use `npx spank --help` for parameters.---
### Config options
| prop |default| description |
|------|-|-------------|
|sitemap|| array of paths. Eg. `['/', '/about', '/contact']`. Can also be a path to a .js file exporting an array of paths. Eg. `./sitemap.js`|
|template|`dist/__app.html`| path to the HTML template to render the SPA in. Often `static/index.html`|
|script|`dist/build/bundle.js`| Path to the app script. Often `dist/build/bundle.js` or `dist/build/main.js`|
|outputDir|`dist`| Folder to save HTML files to.|
|forceIndex|`false`| Write `/about` to `about/index.html` instead of `about.html`|
|inlineDynamicImports|`false`| Required if app uses dynamic imports|
|concurrently|`3`| Max simultaneous running jobs |
|eventName|| If specified, HTMLs aren't saved till the page has emitted the event.|
|host|`http://jsdom.ssr`|Simulated host |
|blacklist|[]|List of paths to be ignored. Regular expressions are supported when using spank.config.js|
|depth|2|How far to crawl any path in the sitemap|
|ssrOptions|{}|Options to be passed to [tossr](https://github.com/roxiness/tossr#config)|
---### How does it work?
For each path in the sitemap, Spank creates a corresponding SPA in a simulated browser. Spank will crawl pages in the sitemap as far as `depth` is set. The HTML for each page is then saved to the output folder.
---