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.jsconst PreRenderPlugin = ; moduleexports = // ... plugins: externals: "framework" test: /\.m?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'].