{"id":13774929,"url":"https://github.com/bengsfort/rollup-plugin-generate-html-template","last_synced_at":"2025-03-05T22:00:23.229Z","repository":{"id":30835648,"uuid":"126141353","full_name":"bengsfort/rollup-plugin-generate-html-template","owner":"bengsfort","description":"Rollup plugin for automatically injecting a script tag with the final bundle into an html file.","archived":false,"fork":false,"pushed_at":"2023-01-03T22:12:57.000Z","size":947,"stargazers_count":60,"open_issues_count":25,"forks_count":19,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T08:03:42.887Z","etag":null,"topics":["html-template","rollup","rollup-plugin"],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bengsfort.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-21T07:42:58.000Z","updated_at":"2024-08-25T11:38:05.000Z","dependencies_parsed_at":"2023-01-14T18:00:28.519Z","dependency_job_id":null,"html_url":"https://github.com/bengsfort/rollup-plugin-generate-html-template","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bengsfort%2Frollup-plugin-generate-html-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bengsfort%2Frollup-plugin-generate-html-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bengsfort%2Frollup-plugin-generate-html-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bengsfort%2Frollup-plugin-generate-html-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bengsfort","download_url":"https://codeload.github.com/bengsfort/rollup-plugin-generate-html-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242111352,"owners_count":20073433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html-template","rollup","rollup-plugin"],"created_at":"2024-08-03T17:01:31.898Z","updated_at":"2025-03-05T22:00:23.193Z","avatar_url":"https://github.com/bengsfort.png","language":"HTML","funding_links":[],"categories":["Plugins"],"sub_categories":["Output"],"readme":"# rollup-plugin-generate-html-template\n\n![build status](https://api.travis-ci.org/bengsfort/rollup-plugin-generate-html-template.svg?branch=master) [![npm version](https://badge.fury.io/js/rollup-plugin-generate-html-template.svg)](https://www.npmjs.com/package/rollup-plugin-generate-html-template) ![code coverage](coverage/coverage.svg)\n\nAuto-inject the resulting rollup bundle via `script` and `link` tags into an HTML template.\n\n## Installation\n\n```shell\nnpm install --save-dev rollup-plugin-generate-html-template\n```\n\n## Usage\n\n```js\n// rollup.config.js\nimport htmlTemplate from 'rollup-plugin-generate-html-template';\n\nexport default {\n  entry: 'src/index.js',\n  dest: 'dist/js/bundle.js',\n  plugins: [\n    htmlTemplate({\n      template: 'src/template.html',\n      target: 'index.html',\n    }),\n  ],\n};\n```\n\nOn final bundle generation the provided template file will have a `script` tag injected directly above the closing `body` tag with a link to the js bundle and similarly a `link` tag above the closing `head` to the css bundle. By default it uses the same file name and places it directly next to the JS bundle.\n\n```html\n\u003c!-- src/index.html --\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eExample\u003c/title\u003e\n  \u003chead\u003e\n\u003cbody\u003e\n  \u003ccanvas id=\"main\"\u003e\u003c/canvas\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n\n\u003c!-- dist/index.html --\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eExample\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" type=\"text/css\" href=\"bundle.css\"\u003e\n  \u003chead\u003e\n\u003cbody\u003e\n  \u003ccanvas id=\"main\"\u003e\u003c/canvas\u003e\n  \u003cscript src=\"bundle.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### Options\n\n- `template`: **(required)** The path to the source template.\n- `target`: The directory and file name to use for the html file generated with the bundle.\n- `attrs`: The attributes provided to the generated bundle script tag. Passed as an array of strings\n  Example: `attrs: ['async', 'defer]` will generate `\u003cscript async defer src=\"bundle.js\"\u003e\u003c/script\u003e`\n- `replaceVars`: An object containing variables that will be replaced in the generated html.\n    Example: `replaceVars: { '__CDN_URL__': process.env.NODE_ENV === 'production' ? 'https://mycdn.com' : '' }` will replace all instances of `__CDN_URL__` with `http://mycdn.com` if the environment is production\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbengsfort%2Frollup-plugin-generate-html-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbengsfort%2Frollup-plugin-generate-html-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbengsfort%2Frollup-plugin-generate-html-template/lists"}