🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

prerender-seo

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prerender-seo

Prerender Javascript rendered pages

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

prerender-seo

Prerender HTML files using Puppeteer.

Install

npm i prerender-seo -D

Usage

const path = require('path')
const prerender = require('prerender-seo')

const files = [
  '/index.html'
]

prerender(
  path.resolve(__dirname, './dist'),
  files,
  {
    // options
  }
)

Test

The test case use a vue-cli generated project

npm run test

Options

NameTypeDefaultDescription
sourceDir{String}-Source directory of static files
files{Array}-HTML Files to prerender
options.destDir{String}*_prerenderDestination directory to store the result
options.proxyTable{Array}[]Proxy to forward any http request that match the config
options.navigationTimeout{Number}30000Define the timeout of any navigation operations
options.resourceInterception{Array}[]Define the regular expression of any resource will be aborted

sourceDir

prerender(
  path.resolve(__dirname, '../dist')
)

files

prerender(
  files: [
    'index.html',
    'about.html',
    'product.html'
  ]
)

options.destDir

Define the destination directory. If you want to replace the source directory, just set the same path as sourceDir.

prerender(
  path.resolve(__dirname, '../dist'),
  files: [
    'index.html',
    'about.html',
    'product.html'
  ],
  {
    destDir: path.resolve(__dirname, '../dist')
  }
)

options.proxyTable

prerender(
  path.resolve(__dirname, '../dist'),
  files: [
    'index.html',
    'about.html',
    'product.html'
  ],
  {
    proxyTable: {
      context: '/api',
      proxy: {
        host: 'example.com',
        port: '80',
        protocol: 'http'
      }
    }
  }
)

options.navigationTimeout

Define the timeout after which any navigation operations will stop trying. (in milli-secs)

prerender(
  path.resolve(__dirname, '../dist'),
  files: [
    'index.html',
    'about.html',
    'product.html'
  ],
  {
    navigationTimeout: 60000
  }
)

options.resourceInterception

Define the regular expression to match any resource url will be aborted before request. The left hand in the array is RegExp pattern, the right hand is RegExp flag.

prerender(
  path.resolve(__dirname, '../dist'),
  files: [
    'index.html',
    'about.html',
    'product.html'
  ],
  {
    resourceInterception: [
      ['hm.baidu.com', 'g'],
      ['/api/tokenAttach', 'g']
    ]
  }
)

FAQs

Package last updated on 10 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts