1.1.0 • Published 4 years ago

webpack-plugin-prerender v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

webpack-plugin-prerender

Prerender HTML and reduce JS while bundling.

Install

$ npm install --save-dev webpack-plugin-prerender

Usage

Make sure, that .html get emitted. Use html-webpack-plugin for example.

// webpack.config.js
const PreRenderPlugin = require("webpack-plugin-prerender");

module.exports = {
  // ...
  plugins: [
    new PreRenderPlugin({
      externals: ["framework"],
      test: /\.m?(ts|js)x?$/,
      functionCalls: ["render"],
      patterns: [],
      exclude: /node_modules/,
      browser: "chromium",
    }),
  ],
};

API

options.externals

Type: Array<libraries: string> Default: []

Use the same externals Array that is used for webpack

options.test

Type: RegExp Default: /\.js\$/

Determines which JS/TS files should be stripped.

options.functionCalls

Type: Array<functionNames: string> Default: []

Which functions should be removed from the bundle.

options.patterns

Type: Array<{ regex: RegExp, value: string }> Default: []

Replace further code from the asset.

options.exclude

Type: RegExp Default: /node_modules/

Which asset files you do not want to change.

options.browser

Type: Browser from Playwright: string Default: chromium

Possible values are 'chromium', 'firefox', 'webkit'.