{"id":20720210,"url":"https://github.com/zaaack/htmls-webpack-plugin","last_synced_at":"2025-08-28T22:22:50.929Z","repository":{"id":57143042,"uuid":"167478867","full_name":"zaaack/htmls-webpack-plugin","owner":"zaaack","description":"A simple, flexible and fast html webpack plugin support multiple htmls","archived":false,"fork":false,"pushed_at":"2021-04-26T07:12:47.000Z","size":78,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-03T21:30:42.322Z","etag":null,"topics":["extensible","fast","flexible","html","html-webpack-plugin","htmls","multiple","multiple-htmls","multiple-pages","plugin","templates","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/zaaack.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}},"created_at":"2019-01-25T03:28:27.000Z","updated_at":"2023-02-13T21:12:45.000Z","dependencies_parsed_at":"2022-09-05T11:50:26.421Z","dependency_job_id":null,"html_url":"https://github.com/zaaack/htmls-webpack-plugin","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/zaaack/htmls-webpack-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fhtmls-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fhtmls-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fhtmls-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fhtmls-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaaack","download_url":"https://codeload.github.com/zaaack/htmls-webpack-plugin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaaack%2Fhtmls-webpack-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272567344,"owners_count":24956785,"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","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["extensible","fast","flexible","html","html-webpack-plugin","htmls","multiple","multiple-htmls","multiple-pages","plugin","templates","webpack","webpack-plugin"],"created_at":"2024-11-17T03:19:38.823Z","updated_at":"2025-08-28T22:22:50.911Z","avatar_url":"https://github.com/zaaack.png","language":"TypeScript","readme":"# htmls-webpack-plugin\n\n[![Build Status](https://travis-ci.org/zaaack/htmls-webpack-plugin.svg?branch=master)](https://travis-ci.org/zaaack/htmls-webpack-plugin) [![npm](https://img.shields.io/npm/v/htmls-webpack-plugin.svg)](https://www.npmjs.com/package/htmls-webpack-plugin) [![npm](https://img.shields.io/npm/dm/htmls-webpack-plugin.svg)](https://www.npmjs.com/package/htmls-webpack-plugin)\n\nSimple, flexible and fast html webpack plugin.\n\n\u003e NOTE: v2 support webpack5, if you still using webpack4, please install htmls-webpack-plugin@v1.0.9\n\n- [htmls-webpack-plugin](#htmls-webpack-plugin)\n  - [Features](#features)\n  - [Install](#install)\n  - [Usage](#usage)\n    - [Options](#options)\n    - [ejs template example](#ejs-template-example)\n    - [Available variables in html templates:](#available-variables-in-html-templates)\n    - [Minify html](#minify-html)\n    - [Example in tests](#example-in-tests)\n  - [Why not html-webpack-plugin](#why-not-html-webpack-plugin)\n  - [License](#license)\n\n## Features\n\n- Simple and flexisble, you can almost controll anything of generate htmls, no need of setup lots of plugins.\n- Support multiple htmls by default\n- Fast, almost 20x faster then html-webpack-plugin for 20+ pages.\n- Rendered via fast \u0026 small template engine [ejs](https://ejs.co/) by default(you can customize via `render` function to use any template engine or just inject script tags string to the html body).\n\n## Install\n\n```sh\nnpm i -D htmls-webpack-plugin\n```\n\n## Usage\n\n### Options\n\n```ts\nconst HtmlsWebpackPlugin = require('htmls-webpack-plugin')\n\nmodule.exports = {\n    plugins: [\n        new HtmlsWebpackPlugin({\n             // optional, hooks\n            beforeEmit: (compilation, compiler) =\u003e void,\n             // optional, hooks\n            afterEmit: (compilation, compiler) =\u003e void,\n             // optional, default is ejs. custom template rendering function, support async rendering,\n            render: (src: string, params: Params) =\u003e string | Promise\u003cstring\u003e,\n            htmls: [{\n                // required, template path\n                src: './index.ejs',\n                // required, string | ((source, src, params) =\u003e string),\n                // output filename,\n                // relative to output path,\n                // can be a function to generate via context\n                filename: 'index.html',\n                // optional, override global render function\n                render: (src: string, params: Params) =\u003e string | Promise\u003cstring\u003e,\n                // optional, override global flushOnDev\n                flushOnDev: boolean | string\n                // optional, custom params when rendering\n                params: () =\u003e object | () =\u003e Promise\u003cobject\u003e | object\n                // optional, transformParams, override global transformParams\n                transformParams?: (params: Params) =\u003e Params \u0026 { [k: string]: any }\n            }],\n\n             /* boolean | string, optional, flush html files to output folder, can be a string file path, useful for debug or devServer. */\n            flushOnDev: false,\n\n             /* optional, override webpackConf's publicPath */\n            publicPath: function | string',\n\n            // optional, custom params when rendering, could be an async function\n            params: () =\u003e object | () =\u003e Promise\u003cobject\u003e | object\n\n            // optional, transform template variables\n            transformParams?: (params: Params) =\u003e Params \u0026 { [k: string]: any }\n        })\n    ]\n}\n\n```\n\n### ejs template example\n\n```html\n\u003c!-- index.ejs --\u003e\n\u003cbody\u003e\n    \u003c% for (let js in entries) {%\u003e\n        \u003cscript src=\"\u003c%= js %\u003e\"\u003e\u003c/script\u003e\n    \u003c% } %\u003e\n\u003c/body\u003e\n```\n\n### Available variables in html templates:\n\n```ts\ninterface Params {\n  entries: string[] // all entrypoints\n  files: string[] // all files\n  jses: string[] // all files ends with .js\n  csses: string[] // all files ends with .css\n  options: Props // plugin props\n  compilation: Compilation // webpack compilation\n  [k: string]: any // custom params via options\n}\n```\n\n### Minify html\n\n1. install [html-minifier](https://github.com/kangax/html-minifier)\n\n```sh\nyarn add -D html-minifier\n```\n\n2. minify your html in`render` function\n\n```ts\nconst HtmlsWebpackPlugin = require('htmls-webpack-plugin')\nconst htmlMinifier = require('html-minifier')\nconst ejs = require('ejs')\n\n// webpack.config.js\nmodule.exports = {\n    ...,\n    plugins: [\n        new HtmlsWebpackPlugin({\n            htmls: [{\n                src: './fixtures/index.ejs',\n                filename: `index.html`,\n                async render(src, params) {\n                    let html = await ejs.renderFile(src, params, { async: true })\n                    return require('html-minifier').minify(html)\n                }\n            }],\n        })\n    ]\n}\n```\n\n### Example in tests\n\n[index.test.ts](https://github.com/zaaack/htmls-webpack-plugin/blob/master/src/test/index.test.ts#L7)\n\n## Why not html-webpack-plugin\n\nhtml-webpack-plugin is really hard to extends and slow for multiple htmls, too much complete features that I don't need. That's why I create this.\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaaack%2Fhtmls-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaaack%2Fhtmls-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaaack%2Fhtmls-webpack-plugin/lists"}