Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dgeibi/simple-prerender-webpack-plugin
Build Time Rendering with webpack and html-webpack-plugin
https://github.com/dgeibi/simple-prerender-webpack-plugin
html-webpack-plugin prerender webpack webpack-plugin
Last synced: 1 day ago
JSON representation
Build Time Rendering with webpack and html-webpack-plugin
- Host: GitHub
- URL: https://github.com/dgeibi/simple-prerender-webpack-plugin
- Owner: dgeibi
- License: other
- Created: 2018-02-21T10:41:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-07T07:00:04.000Z (about 6 years ago)
- Last Synced: 2024-12-14T09:06:18.463Z (13 days ago)
- Topics: html-webpack-plugin, prerender, webpack, webpack-plugin
- Language: JavaScript
- Homepage:
- Size: 1.25 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-prerender-webpack-plugin
[![version][version-badge]][package]
## Features
- Based on Promise
- Support dynamic import
- Sourcemap: to enable sourcemap just configure webpack with `devtool: source-map`
- Inject rendering result into html-webpack-plugin as `htmlWebpackPlugin.options.prerendered`## Install
```sh
$ npm install webpack html-webpack-plugin@next
$ npm install simple-prerender-webpack-plugin
```## Examples
- [examples](examples)
- [dgeibi/yarb](https://github.com/dgeibi/yarb)## Usage
`webpack.config.js`:
```js
const SimplePrerenderWebpackPlugin = require('simple-prerender-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')module.exports = {
entry: './src/index.js',plugins: [
new HtmlWebpackPlugin({
filename: 'page1.html',
template: './src/template.ejs',
}),
new HtmlWebpackPlugin({
filename: 'page2.html',
template: './src/template.ejs',
}),
new SimplePrerenderWebpackPlugin({
// (optional) path to file which exports a prerender function
//
// defaults to './src/index.js'
entry: './src/ssr.js',// (optional)
// : path to partial webpack config
// : partial webpack config
config: {
plugins: [],
externals: [],
entry: './src/ssr.js',
module: {},
},// (optional): filename of output
filename: 'prerender.js',// (optional):
chunkFilename: 'prerender.[id].js',// (optional): , see `examples/multi-instance`
id: '',// (optional): whether write output to disk
writeToDisk: false,// (optional): opts passed to webpack-node-externals
// see also https://www.npmjs.com/package/webpack-node-externals
nodeExternalsOptions: {},
}),
],
}
````./src/template.ejs`:
```ejs
<%= htmlWebpackPlugin.options.title %><%= htmlWebpackPlugin.options.prerendered %>```
`./src/ssr.js`:
```js
export default ({
outputName, // html filename
plugin, // html-webpack-plugin instance
assets, // html-webpack-plugin assets
compilation,
compiler,
}) => {
return `${outputName}`
}
```## LICENSE
[MIT](LICENSE)
[version-badge]: https://img.shields.io/npm/v/simple-prerender-webpack-plugin.svg
[package]: https://www.npmjs.com/package/simple-prerender-webpack-plugin