{"id":25934377,"url":"https://github.com/sanand0/rollup-plugin-htmlparts","last_synced_at":"2026-02-15T23:33:27.439Z","repository":{"id":143906855,"uuid":"174719906","full_name":"sanand0/rollup-plugin-htmlparts","owner":"sanand0","description":"Loads HTML templates as a module","archived":false,"fork":false,"pushed_at":"2024-12-25T11:51:50.000Z","size":48,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-02-14T03:14:10.736Z","etag":null,"topics":["library","tool"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/sanand0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-09T16:44:42.000Z","updated_at":"2025-04-17T07:01:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"d7715b83-2802-4612-9a38-37ba4b306e5f","html_url":"https://github.com/sanand0/rollup-plugin-htmlparts","commit_stats":null,"previous_names":["sanand0/rollup-plugin-htmlparts","gramener/rollup-plugin-htmlparts"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/sanand0/rollup-plugin-htmlparts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanand0%2Frollup-plugin-htmlparts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanand0%2Frollup-plugin-htmlparts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanand0%2Frollup-plugin-htmlparts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanand0%2Frollup-plugin-htmlparts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sanand0","download_url":"https://codeload.github.com/sanand0/rollup-plugin-htmlparts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sanand0%2Frollup-plugin-htmlparts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29492619,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T19:29:10.908Z","status":"ssl_error","status_checked_at":"2026-02-15T19:29:10.419Z","response_time":118,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["library","tool"],"created_at":"2025-03-04T00:57:37.413Z","updated_at":"2026-02-15T23:33:27.422Z","avatar_url":"https://github.com/sanand0.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rollup-plugin-htmlparts\n\n[![Build Status](https://travis-ci.com/sanand0/rollup-plugin-htmlparts.svg)](https://travis-ci.com/sanand0/rollup-plugin-htmlparts)\n\nThis helps you import HTML snippets into JavaScript variables using modules.\n\nSuppose you want this in your `index.js`:\n\n```js\nvar heading = '\u003ch1\u003eThis is the \u003cem\u003eheading\u003c/em\u003e\u003c/h1\u003e'\nvar body = '\u003cp\u003eThis is the \u003cstrong\u003ebody\u003c/strong\u003e.\u003c/p\u003e'\n```\n\n... but prefer to use HTML files to save HTML (for syntax-highlighting, etc.),\nthen create a HTML file like this (called, for example, `template.html`):\n\n```html\n\u003c!-- var heading --\u003e\n  \u003ch1\u003eThis is the \u003cem\u003eheading\u003c/em\u003e\u003c/h1\u003e\n\u003c!-- end --\u003e\n\n\u003c!-- var body --\u003e\n  \u003cp\u003eThis is the \u003cstrong\u003ebody\u003c/strong\u003e.\u003c/p\u003e\n\u003c!-- end --\u003e\n```\n\nSet up your `rollup.config.js` like this:\n\n```js\nimport htmlparts from 'rollup-plugin-htmlparts'\n\nexport default [\n  {\n    input: 'index.js',\n    output: { file: \"index.min.js\", name: \"package\", format: \"umd\" },\n    plugins: [htmlparts('template.html')]\n  }\n]\n```\n\nNow, in the `index.js` mentioned above, you can import variables from\n`template.html`.\n\n```js\nimport { heading, body } from './template.html'\n```\n\nRun `node_modules/.bin/rollup -c` to create the `index.min.js`, which\nwill have the imported variables.\n\n## HTML structure\n\nAnything enclosed within `\u003c!-- var \u003cname\u003e --\u003e ... \u003c!-- end --\u003e` is treated as\na HTML string and assigned to the variable `\u003cname\u003e`.\n\nThe string is minified by [HTML Minifier](http://npmjs.com/package/html-minifier)\nwith these options:\n\n- `collapseBooleanAttributes: true`\n- `collapseInlineTagWhitespace: true`\n- `collapseWhitespace: true`\n- `decodeEntities: true`\n- `removeComments: true`\n\n## Installation\n\n```sh\nnpm install rollup-plugin-htmlparts\n```\n\n## Changelog\n\n- 1.0.0: 9 Mar 2019 - Initial release\n- 1.1.1: 9 Mar 2019 - Switch to ES6 modules\n- 1.1.2: 10 Mar 2019 - Works on ES6 modules and CJS\n- 1.2.0: 19 Mar 2019 - Ignores whitespace in `\u003c!-- var --\u003e` and `\u003c!-- end --\u003e`\n- 1.2.1: 4 Jan 2022 - Upgrade packages for security vulnerabilities\n- 1.2.2: 23 Nov 2022 - Upgrade packages for security vulnerabilities\n- 1.2.3: 25 Dec 2024 - Upgrade links\n\n## Release\n\n```sh\n# Update package.json version\n# Update Changelog in README.md\nnpm test\ngit commit . -m\"DOC: Release version x.x.x\"\ngit push\n# Ensure that there are no CI build errors\ngit tag -a vx.x.x -m\"Add a one-line summary\"\ngit push --follow-tags\nnpm publish     # maintainer: sanand0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanand0%2Frollup-plugin-htmlparts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsanand0%2Frollup-plugin-htmlparts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsanand0%2Frollup-plugin-htmlparts/lists"}