# @neutrinojs/html-template

> Neutrino middleware for automatic HTML file generation from metadata

Latest version **9.5.0** (published 2020-12-23) · MPL-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @neutrinojs/html-template
pnpm add @neutrinojs/html-template
yarn add @neutrinojs/html-template
bun add @neutrinojs/html-template
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 9.5.0 |
| Published | 2020-12-23 |
| First published | 2017-12-07 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 22.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3905 |
| Author | Eli Perelman |
| Maintainers | edmorley, helfi92, timkelty, eliperelman |
| Keywords | neutrino, neutrino-middleware, html, template |

## Links

- npm: https://www.npmjs.com/package/@neutrinojs/html-template
- Repository: https://github.com/neutrinojs/neutrino
- Homepage: https://neutrinojs.org
- Issues: https://github.com/neutrinojs/neutrino/issues
- npm.io page: https://npm.io/package/@neutrinojs/html-template

## Dependencies (1)

- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^4.5.0

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 9.5.0 (latest) — 2020-12-23
- 9.4.0 — 2020-08-28
- 9.3.0 — 2020-07-16
- 9.2.0 — 2020-06-07
- 9.1.0 — 2020-01-28
- 9.0.0 — 2019-12-13
- 9.0.0-rc.5 — 2019-11-13
- 9.0.0-rc.4 — 2019-10-06
- 9.0.0-rc.3 — 2019-05-08
- 9.0.0-rc.2 — 2019-05-08
- 9.0.0-rc.1 — 2019-04-16
- 9.0.0-rc.0 — 2018-11-26
- 9.0.0-beta.1 — 2018-10-23
- 9.0.0-beta.0 — 2018-09-20
- 8.3.0 — 2018-06-27
- … 37 more at https://npm.io/package/@neutrinojs/html-template/versions

## README

# Neutrino HTML Template Middleware

`@neutrinojs/html-template` is Neutrino middleware for automatically creating
HTML files for configured entry points.

[![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url]

## Requirements

- Node.js 10+
- Yarn v1.2.1+, or npm v5.4+
- Neutrino 9
- webpack 4

## Installation

`@neutrinojs/html-template` can be installed via the Yarn or npm clients.

#### Yarn

```bash
❯ yarn add --dev @neutrinojs/html-template
```

#### npm

```bash
❯ npm install --save-dev @neutrinojs/html-template
```

## Usage

`@neutrinojs/html-template` can be consumed from the Neutrino API, middleware,
or presets. Require this package and plug it into Neutrino:

```js
const htmlTemplate = require('@neutrinojs/html-template');

// Usage shows default values
// Accepts options specified by html-webpack-plugin:
// https://github.com/jantimon/html-webpack-plugin#configuration
neutrino.use(
  htmlTemplate({
    // @neutrinojs/html-template includes a custom template that has more features
    // (eg appMountId and lang support) than the default html-webpack-plugin template:
    // https://github.com/jantimon/html-webpack-plugin/blob/master/default_index.ejs
    template: require.resolve('@neutrinojs/html-template/template.ejs'),
    appMountId: 'root',
    lang: 'en',
    meta: {
      viewport: 'width=device-width, initial-scale=1',
    },
    // Override pluginId to add an additional html-template plugin instance
    pluginId: 'html',
  }),
);

// Most commonly, you will want to override the initial page title:
neutrino.use(
  htmlTemplate({
    title: 'React Application',
  }),
);
```

```js
// Using in .neutrinorc.js
const htmlTemplate = require('@neutrinojs/html-template');

// Usage shows default values
// Accepts options specified by html-webpack-plugin:
// https://github.com/jantimon/html-webpack-plugin#configuration
module.exports = {
  use: [
    htmlTemplate({
      // @neutrinojs/html-template includes a custom template that has more features
      // (eg appMountId and lang support) than the default html-webpack-plugin template:
      // https://github.com/jantimon/html-webpack-plugin/blob/master/default_index.ejs
      template: require.resolve('@neutrinojs/html-template/template.ejs'),
      appMountId: 'root',
      lang: 'en',
      meta: {
        viewport: 'width=device-width, initial-scale=1',
      },
      // Override pluginId to add an additional html-template plugin instance
      pluginId: 'html',
    }),
  ],
};

// Most commonly, you will want to override the initial page title:
module.exports = {
  use: [
    htmlTemplate({
      title: 'React Application',
    }),
  ],
};
```

## Customization

`@neutrinojs/html-template` creates some conventions to make overriding the
configuration easier once you are ready to make changes.

### Plugins

The following is a list of plugins and their identifiers which can be
overridden:

| Name   | Description                                                     | NODE_ENV |
| ------ | --------------------------------------------------------------- | -------- |
| `html` | Automatically generates HTML files for configured entry points. | all      |

## Contributing

This middleware is part of the
[neutrino](https://github.com/neutrinojs/neutrino) repository, a monorepo
containing all resources for developing Neutrino and its core presets and
middleware. Follow the
[contributing guide](https://neutrinojs.org/contributing/) for details.

[npm-image]: https://img.shields.io/npm/v/@neutrinojs/html-template.svg
[npm-downloads]: https://img.shields.io/npm/dt/@neutrinojs/html-template.svg
[npm-url]: https://www.npmjs.com/package/@neutrinojs/html-template

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