# rollup-plugin-gen-html

> rollup plugin for generating html file from template & injecting bundled files

Latest version **0.2.7** (published 2020-02-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-gen-html
pnpm add rollup-plugin-gen-html
yarn add rollup-plugin-gen-html
bun add rollup-plugin-gen-html
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.7 |
| Published | 2020-02-29 |
| First published | 2018-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >8.0.0 |
| Dependencies | 4 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | scrollbar-ww |
| Maintainers | scrollbar |
| Keywords | postcss, color, mix |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-gen-html
- Repository: https://github.com/cheap-pets/rollup-plugin-gen-html
- Homepage: https://github.com/cheap-pets/rollup-plugin-gen-html#readme
- Issues: https://github.com/cheap-pets/rollup-plugin-gen-html/issues
- npm.io page: https://npm.io/package/rollup-plugin-gen-html

## Dependencies (4)

- [hasha](https://npm.io/package/hasha.md) ^3.0.0
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [rollup-pluginutils](https://npm.io/package/rollup-pluginutils.md) ^2.3.3

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 0.2.7 (latest) — 2020-02-29
- 0.2.6 — 2019-11-14
- 0.2.5 — 2019-05-15
- 0.2.4 — 2019-03-19
- 0.2.3 — 2019-03-15
- 0.2.2 — 2019-03-14
- 0.2.1 — 2018-12-11
- 0.2.0 — 2018-12-11
- 0.1.3 — 2018-12-10
- 0.1.2 — 2018-12-10
- 0.1.1 — 2018-10-18
- 0.1.0 — 2018-10-18

## README

# rollup-plugin-gen-html

generate html file & inject bundled files



### Installation

```
npm install rollup-plugin-gen-html -D
```

or

```
yarn add rollup-plugin-gen-html --dev
```



### Usage

#### Minimal

it can be zero config to bundle with  `.vue` files.

`rollup.config.js` :

``` js
import html from 'rollup-plugin-gen-html' // this plugin
import postcss from 'rollup-plugin-postcss' // handle .pcss files

export default {
    input: 'src/index.js',
    output: {
        file: 'dist/app.js'
    },
    plugins: [
        html(),
        postcss({ /* postcss plugin options */ })
    ]
}
```

`src/index.js` :

```
import './index.html'  // import as template
import './css/index.pcss' // 
```

`src/index.html`

``` html
<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Example</title>
  </head>
  <body>
    <div id="app"></div>
    <script type="text/javascript" src="./lib/vue/vue.runtime.js"></script>
  </body>
</html>
```



##### output :

`dist/index.html`

``` html
<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Example</title>
    <link rel="stylesheet" type="text/css" href="app.css">
  </head>
  <body>
    <div id="app"></div>
    <script type="text/javascript" src="./lib/vue/vue.runtime.min.js"></script>
    <script type="text/javascript" src="app.js"></script>
  </body>
</html>
```



#### options

##### include

* type: `string`
* default: `**/*.html`

files that will be handled



##### exclude

- type: `string`
- default: `undefined`

files that will be ignored



##### template

* type: `string`
* default: `undefined`

Specify a html file, and load the content as template.

If there are html files that import within scripts, this option will be ignored.

in some cases, you need to specify a template by environment variable or arguments, use this option.



##### output

- type: `string`
- default: `undefined`

output path of the html file(s)，related to `cwd`.

If has a single html file, it can be a file path, otherwise it should be a directory.



##### hash

- type: `string | boolean`
- default: `false`

Put a md5 value of the bundle file, or use the specify string value, as part of the bundle filenames.

Then, the output html file looks like:

`dist/index.html`

```html
<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Example</title>
    <link rel="stylesheet" type="text/css" href="app.2234a93729a0e7115216f9a5d55f93c4.css">
  </head>
  <body>
    <div id="app"></div>
    <script type="text/javascript" src="./lib/vue/vue.runtime.min.js"></script>
    <script type="text/javascript" src="app.b572d3ac186ca60072b05e7892848a73.js"></script>
  </body>
</html>
```



##### replaceToMinScripts

- type: `boolean`
- default: `true`

Auto replace script src to `*.min.js` , if exist.



##### insertCssRef

- type: `boolean`
- default: `true`

Insert `css` file ref into html content, if exist.

---
_Source: https://npm.io/package/rollup-plugin-gen-html · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
