Prerenders static HTML in a single-page application.
page.goto()
call using new PuppeteerRenderer({rendererOptions: Object})
. See README.md. (Thanks @cbravo!)DeprecationWarning: Tapable.plugin is deprecated
warning in Webpack 4. (Thanks @qkdreyer!)3.2.0
Included accidental log statement.compiler.outputFileSystem
to write files instead of fs
and mkdirp-promise
. Should work exactly the same way in 99.9% of use-cases, and fix an issue in the last 0.1%prerenderer
to 0.7.1
to fix handling of Unicode and non-URL characters in route paths.context
object in postProcess
, a clearer error is thrown.postProcess
now allows you to overwrite context.outputPath
. It is null by default but will be used if set. Otherwise, it will continue to calculate the output path as normal. Can be used to write files that end with a file extension directly instead of writing them to index.html
in a folder by the same name. (#179) See README.prerender-spa-plugin 2.x was developed around PhantomJS and closely integrated with it to provide prerendering support. Unfortunately, PhantomJS has been falling behind in terms of support for modern web platform features, often requiring unwieldy polyfills. In the meantime, alternatives such as puppeteer have filled the void left by PhantomJS.
However, it was impossible for us to maintain full backwards-compatibility with prerender-spa-plugin 2.x while also switching out the rendering backend, so instead we took this as an opportunity to modularize the plugin and make a few much-needed changes while also replacing PhantomJS with puppeteer.
For clarification, basic usage of prerender-spa-plugin 3 is still backwards-compatible with 2.x, but deprecated. For obvious reasons, custom configuration of PhantomJS will no longer function.
new PrerenderSPAPlugin(staticDir: String, routes: Array<String>, config: Object)
to new PrerenderSPAPlugin(config: Object). For example: new PrerenderSPAPlugin({ staticDir: String, routes: String, })
window['__PRERENDER_INJECTED']
when the pages are rendered. (The window destination property can be configured with injectProperty: String
)npm install @prerenderer/renderer-jsdom
. and require('@prerenderer/renderer-jsdom')
.new PrerenderSPAPlugin({
staticDir: path.join(__dirname, 'dist'),
routes: ['/', '/about', '/config'],
// This allows other renderers to be implemented with a
// subset or superset of features.
renderer: new PrerenderSPAPlugin.PuppeteerRenderer({
inject: {foo: 'bar'},
renderAfterDocumentEvent: 'render-event',
headless: false
})
})
DEPRECATION: captureAfter*
configuration values have moved to the renderer configuration and renamed to renderAfter*
for consistency. You can still use captureAfter*
but you will recieve a deprecation warning.
DEPRECATION: Attempting to use the old style plugin initialization new PrerenderSPAPlugin(staticDir: String, routes: Array<String>, config: Object)
will result in a deprecation warning.
DEPRECATION: postProcessHtml
has been replaced with postProcess
which allows processing HTML as well as adjusting the output routes. Using postProcessHtml
should still function, but result in a deprecation warning.
BREAKING: captureAfter* / renderAfter*
options can no longer be mixed, as this could sometimes result in confusing behavior or race conditions. Pick one and stick with it.
BREAKING: Renderers must be configured in their own initializers, separately from the plugin. (See the example above.)
BREAKING: PhantomJS options are no longer supported. You can, however pass launch options to the configuration for the Puppeteer renderer. The full list of options is available here.
phantomjs-prebuilt
dependency to 2.1.8
; was 2.1.7
. (#83)outputDir
to allow custom output directory of static HTML. (#38)indexPath
to allow customization of default index.html
path. (#81)phantomPageViewportSize
to adjust default PhantomJS viewport dimensions. (#73)core-js
is more reliable. (#54)ignoreJSErrors
option is available to quietly swallow errorspostProcessHTML
option is available for edge cases to (fixes #19)ignoreJSErrors
option