# rollup-plugin-index

> Rollup plugin to inject script and link tags into a HTML template.

Latest version **1.1.4** (published 2020-08-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-index
pnpm add rollup-plugin-index
yarn add rollup-plugin-index
bun add rollup-plugin-index
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2020-08-13 |
| First published | 2019-06-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 379.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Curtis Maloney |
| Maintainers | funkybob |
| Keywords | rollup, plugin, rollup-plugin |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-index
- npm.io page: https://npm.io/package/rollup-plugin-index

## Dependencies (1)

- [parse5](https://npm.io/package/parse5.md) ^6.0.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.1.4 (latest) — 2020-08-13
- 1.1.3 — 2020-05-02
- 1.1.1 — 2020-03-25
- 1.1.0 — 2020-03-25
- 1.0.0 — 2019-06-14

## README

# rollup-plugin-index
A Rollup plugin to inject you assets into a HTML template.

# Install

    $ npm install -D rollup-plugin-index

# Configure

Add to the plugins section of your rollup.config.js:

    import Index from 'rollup-plugin-index'

    export default {
      input: 'test/main.js',
      output: {
        file: 'dist/bundle.js',
        format: 'es'
      },
      plugins: [
        Index({
          source: 'index.html',
          compact: true
        })
      ]
    }


# Create your HTML template

    <!DOCTYPE html>
    <html>
      <head>
        <title> My Site! </title>
      </head>
      <body>
        <h1> Whoa! </h1>
      </body>
    </html>

# Generate!

    $ npx rollup -c

And you should find something like this in `dist/index.html`:

    <!DOCTYPE html><html><head><title> My Site! </title><script type="module" src="bundle.js"></script></head><body> <h1> Whoa! </h1> </body></html>

Since ``compact`` was set, all text nodes that are direct children of <html> and <head> are removed, and all text nodes in <body> will be trimmed.

# Options

source::

    Template to use

compact:: (Default: false)

    Should remove text node children from <html> and <head>.

target::

    Filename / path to write output to.
    If not specified, it will use the basename of the source file.

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