headless-spa-prerender

0.4.1 • Public • Published

headless-spa-prerender

Pre-render single page application states and save as static HTML pages.

$ npm install headless-spa-prerender --save-dev

Synopsis

prerender(...pages: Array<string>, destination: string, options?: Object)

Parameters

  • pages <Array> - list of URLs to parse.
  • destination <string> - output directory.
  • options <Object> - optional.
    • pendingScripts <Array> - list of script names to load before parsing. You can also specify a part of the names (e.g. "bundle" for "bundle-1.js", "bundle-2.js", etc.).
    • clearTags <Array|false> - list of tags to remove before saving. Default: ['scripts'].
    • renderTimeout <int> - timeout for render page DOM before parsing. Default: 1000ms.

Example

const prerender = require('headless-spa-prerender');
 
const host = 'https://promonavigator.co.id';
 
const pageUrls = [
    `${host}/about`,
    `${host}/contacts`,
    `${host}/faq`,
    `${host}/index`,
    `${host}/prices`,
    `${host}/ref-land`,
];
 
prerender(pageUrls, './prerendered', {
    pendingScripts: ['core.js', 'front-office-2.js'],
    clearTags: ['script', 'iframe'],
    renderTimeout: 2000
});

License

MIT License

Package Sidebar

Install

npm i headless-spa-prerender

Weekly Downloads

1

Version

0.4.1

License

MIT

Unpacked Size

4.85 kB

Total Files

3

Last publish

Collaborators

  • vies