{"_id":"generate-page-webpack-plugin","_rev":"471544","name":"generate-page-webpack-plugin","description":"[![Greenkeeper badge](https://badges.greenkeeper.io/storybooks/generate-page-webpack-plugin.svg)](https://greenkeeper.io/)","dist-tags":{"latest":"1.1.1"},"maintainers":[{"name":"ndelangen","email":""},{"name":"pksunkara","email":"pavan.sss1991@gmail.com"}],"time":{"modified":"2021-08-05T08:20:25.000Z","created":"2018-07-26T06:49:50.208Z","1.1.1":"2018-09-23T11:46:59.189Z","1.1.0":"2018-09-07T09:26:05.188Z","1.0.0":"2018-07-26T06:49:50.208Z"},"users":{},"author":"","repository":{"type":"git","url":"git+https://github.com/storybooks/generate-page-webpack-plugin.git"},"versions":{"1.1.1":{"name":"generate-page-webpack-plugin","version":"1.1.1","description":"[![Greenkeeper badge](https://badges.greenkeeper.io/storybooks/generate-page-webpack-plugin.svg)](https://greenkeeper.io/)","keywords":[],"homepage":"https://github.com/storybooks/generate-page-webpack-plugin#readme","bugs":{"url":"https://github.com/storybooks/generate-page-webpack-plugin/issues"},"repository":{"type":"git","url":"git+https://github.com/storybooks/generate-page-webpack-plugin.git"},"license":"MIT","author":"","main":"index.js","gitHead":"c9db3fab3d3861c6c24a0ec9c4e4c19f6266bd43","_id":"generate-page-webpack-plugin@1.1.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.3","_npmUser":{"name":"ndelangen","email":"ndelangen@me.com"},"dist":{"shasum":"82208fb599f45d70940cbd6327a7a46e77c5ee2c","size":2766,"noattachment":false,"key":"/generate-page-webpack-plugin/-/generate-page-webpack-plugin-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/generate-page-webpack-plugin/download/generate-page-webpack-plugin-1.1.1.tgz"},"maintainers":[{"name":"ndelangen","email":""},{"name":"pksunkara","email":"pavan.sss1991@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/generate-page-webpack-plugin_1.1.1_1537703219066_0.33569022934429604"},"_hasShrinkwrap":false,"publish_time":1537703219189,"_cnpm_publish_time":1537703219189},"1.1.0":{"name":"generate-page-webpack-plugin","version":"1.1.0","description":"[![Greenkeeper badge](https://badges.greenkeeper.io/storybooks/generate-page-webpack-plugin.svg)](https://greenkeeper.io/)","keywords":[],"homepage":"https://github.com/storybooks/generate-page-webpack-plugin#readme","bugs":{"url":"https://github.com/storybooks/generate-page-webpack-plugin/issues"},"repository":{"type":"git","url":"git+https://github.com/storybooks/generate-page-webpack-plugin.git"},"license":"MIT","author":"","main":"index.js","gitHead":"bdd5eac1679bf9cb84bc10deb1f66ebd2cc62c17","_id":"generate-page-webpack-plugin@1.1.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.3","_npmUser":{"name":"ndelangen","email":"ndelangen@me.com"},"dist":{"shasum":"5940c9c6bdbfa03b1a4ef8f909875d5ebafbd3af","size":2752,"noattachment":false,"key":"/generate-page-webpack-plugin/-/generate-page-webpack-plugin-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/generate-page-webpack-plugin/download/generate-page-webpack-plugin-1.1.0.tgz"},"maintainers":[{"name":"ndelangen","email":""},{"name":"pksunkara","email":"pavan.sss1991@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/generate-page-webpack-plugin_1.1.0_1536312364998_0.907123987918147"},"_hasShrinkwrap":false,"publish_time":1536312365188,"_cnpm_publish_time":1536312365188},"1.0.0":{"name":"generate-page-webpack-plugin","version":"1.0.0","description":"Generate HTML-pages for every webpack entrypoint","keywords":[],"homepage":"https://github.com/storybooks/generate-page-webpack-plugin#readme","bugs":{"url":"https://github.com/storybooks/generate-page-webpack-plugin/issues"},"repository":{"type":"git","url":"git+https://github.com/storybooks/generate-page-webpack-plugin.git"},"license":"MIT","author":"","main":"index.js","gitHead":"1365f1fa14a7ca4d15070c26d915fda23d05fee8","_id":"generate-page-webpack-plugin@1.0.0","_npmVersion":"6.1.0","_nodeVersion":"10.6.0","_npmUser":{"name":"ndelangen","email":"ndelangen@me.com"},"dist":{"shasum":"e6261efb7e6b9ef8a8136126b14fa26aedfb7f33","size":2704,"noattachment":false,"key":"/generate-page-webpack-plugin/-/generate-page-webpack-plugin-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/generate-page-webpack-plugin/download/generate-page-webpack-plugin-1.0.0.tgz"},"maintainers":[{"name":"ndelangen","email":""},{"name":"pksunkara","email":"pavan.sss1991@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/generate-page-webpack-plugin_1.0.0_1532587790162_0.8953907577296032"},"_hasShrinkwrap":false,"publish_time":1532587790208,"_cnpm_publish_time":1532587790208}},"readme":"# Generate Page Webpack Plugin\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/storybooks/generate-page-webpack-plugin.svg)](https://greenkeeper.io/)\n\nGenerate HTML-pages for every webpack entrypoint\n\n## Install\n\n```sh\nnpm install generate-page-webpack-plugin --dev --save\n```\n```sh\nyarn add generate-page-webpack-plugin --dev\n```\n\n## Add to your webpack config\n\n```js // webpack.config.js\nexport const config = {\n  mode: 'development',\n  devtool: 'cheap-module-source-map',\n  entry: {\n    page1: ['pages/page1.js'],\n    page2: ['pages/page2.js'],\n  },\n  plugins: [\n    new GeneratePagePlugin(\n      {\n        template: require.resolve('../templates/index.html.ejs'),\n        parser: require('ejs'),\n      },\n      {\n        data: {\n          awesome: true,\n        },\n      }\n    ),\n  ],\n};\n```\n\n## Api\n\n`GeneratePagePlugin` takes 2 parameters: \n\n### Config\n\nConfig is data the plugin needs to operate, it will not be passed to the template\n\n- **parser** - *required* - should be a ejs like module that can `compile` and invoke templates\n- **template** - *required* - the template to use to generate pages\n- **filename** - *optional* - should be a function that takes the entrypoint name and returns a name for the html-file.\n\nProperties *have no default*, so if they are required you must supply them!\n\n### Options\n\nOptions are datapoints that are used when generating the template, they are passed to the template.\n\nIf the value of a option is a function, it will be invoked with the name of the entry, so you can change the options per entry!\n\nYou can set whatever options you want here, you're totally free to make up your own data (different per entry is possible) and inject it into the template.\n\nHere's a few suggestions:\n\n- **headHtmlSnippet** - inject some html into the head\n- **footHtmlSnippet** - inject some html into the foot\n- **script** - inject scripts\n- **window** - inject global scope variables\n- **title** - meta title for the page\n\n## Templates\n\nTemplates can be in whatever syntax you like, if you supply a parser for them.\nWe do not ship with a parser or template included.\n\n### Rendering chunks and options\n\nThe template will be provided with the data which is a combination of:\n\n- the webpack entrypoint reference\n  **values are accessible as global variables** The most useful is likely `chunks`.\n\n- the webpack compilation\n  **values are available under a variable called `compilation`**.\n- the dlls needed for the entrypoint\n  **values are available under a variable called `dlls`**.\n  Dlls are an advanced use-case but with this plugin there should be no special setup required for them to be injected into the template. __But you do need to render them in the template__ (see example).\n- the options\n  **values are available under a variable called `options`**.\n  If the option was a function in the webpack config, by the time the data is injected into the template it will have been called and whatever the function returned for that property, that's what's injected into the template.\n\n### Template example\n\n```ejs\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <meta content=\"IE=edge\" http-equiv=\"X-UA-Compatible\" />\n    <title><%= options.title %></title>\n    <link rel=\"shortcut icon\" href=\"favicon.ico\" />\n  \n    <% if (options.headHtmlSnippet) { %>\n      <%- options.headHtmlSnippet %>\n    <% } %>\n  \n</head>\n<body>\n    \n    <% if (options.window) { %>\n      <script>\n        <% for (key in options.window) { %>\n          window['<%= key %>'] = <%= JSON.stringify(options.window[key]) %>;\n        <% } %>\n      </script>\n    <% } %>\n\n    <% if (options.bodyHtmlSnippet) { %>\n      <%- options.bodyHtmlSnippet %>\n    <% } %>\n  \n    <div id=\"root\"></div>\n\n    <% for (key in dlls) { %>\n      <script src=\"<%= compilation.outputOptions.publicPath %><%= dlls[key] %>\" defer></script>\n    <% } %>\n  \n    <% for (index in chunks) { %>\n      <% for (key in chunks[index].files) { %>\n        <script src=\"<%= compilation.outputOptions.publicPath %><%= chunks[index].files[key] %>\" defer></script>\n      <% } %>\n    <% } %>\n  \n</body>\n</html>\n```\n\n## Contributing\n\nAll contributions are welcome!\n","_attachments":{},"homepage":"https://github.com/storybooks/generate-page-webpack-plugin#readme","bugs":{"url":"https://github.com/storybooks/generate-page-webpack-plugin/issues"},"license":"MIT"}