1 | # Neutrino HTML Template Middleware
|
2 | [![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url] [![Join Slack][slack-image]][slack-url]
|
3 |
|
4 | `neutrino-middleware-html-template` is Neutrino middleware for automatically creating HTML files for configured
|
5 | entry-points.
|
6 |
|
7 | ## Requirements
|
8 |
|
9 | - Node.js v6.10+
|
10 | - Yarn or npm client
|
11 | - Neutrino v6
|
12 |
|
13 | ## Installation
|
14 |
|
15 | `neutrino-middleware-html-template` can be installed via the Yarn or npm clients.
|
16 |
|
17 | #### Yarn
|
18 |
|
19 | ```bash
|
20 | ❯ yarn add neutrino-middleware-html-template
|
21 | ```
|
22 |
|
23 | #### npm
|
24 |
|
25 | ```bash
|
26 | ❯ npm install --save neutrino-middleware-html-template
|
27 | ```
|
28 |
|
29 | ## Usage
|
30 |
|
31 | `neutrino-middleware-html-template` can be consumed from the Neutrino API, middleware, or presets. Require this package
|
32 | and plug it into Neutrino:
|
33 |
|
34 | ```js
|
35 | // Using function middleware format
|
36 | const template = require('neutrino-middleware-html-template');
|
37 |
|
38 | // Usage shows default values
|
39 | // Accepts options specified by HtmlWebpackTemplate
|
40 | // https://github.com/jaketrent/html-webpack-template
|
41 | neutrino.use(template, {
|
42 | inject: false,
|
43 | appMountId: 'root',
|
44 | xhtml: true,
|
45 | mobile: true,
|
46 | minify: {
|
47 | useShortDoctype: true,
|
48 | keepClosingSlash: true,
|
49 | collapseWhitespace: true,
|
50 | preserveLineBreaks: true
|
51 | }
|
52 | });
|
53 |
|
54 | // Most commonly, you will want to override the initial page title:
|
55 | neutrino.use(template, {
|
56 | title: 'React Application'
|
57 | });
|
58 | ```
|
59 |
|
60 | ```js
|
61 | // Using object or array middleware format
|
62 |
|
63 | // Usage shows default values
|
64 | // Accepts options specified by HtmlWebpackTemplate
|
65 | // https://github.com/jaketrent/html-webpack-template
|
66 | module.exports = {
|
67 | use: [
|
68 | ['neutrino-middleware-html-template', {
|
69 | inject: false,
|
70 | appMountId: 'root',
|
71 | xhtml: true,
|
72 | mobile: true,
|
73 | minify: {
|
74 | useShortDoctype: true,
|
75 | keepClosingSlash: true,
|
76 | collapseWhitespace: true,
|
77 | preserveLineBreaks: true
|
78 | }
|
79 | }]
|
80 | ]
|
81 | };
|
82 |
|
83 | // Most commonly, you will want to override the initial page title:
|
84 | module.exports = {
|
85 | use: [
|
86 | ['neutrino-middleware-html-template', {
|
87 | title: 'React Application'
|
88 | }]
|
89 | ]
|
90 | };
|
91 | ```
|
92 |
|
93 | ## Customization
|
94 |
|
95 | `neutrino-middleware-html-template` creates some conventions to make overriding the configuration easier once you are ready to
|
96 | make changes.
|
97 |
|
98 | ### Plugins
|
99 |
|
100 | The following is a list of plugins and their identifiers which can be overridden:
|
101 |
|
102 | | Name | Description | Environments |
|
103 | | ---- | ----------- | ------------ |
|
104 | | `html` | Automatically generates HTML files for configured entry-points. | all |
|
105 |
|
106 | ## Contributing
|
107 |
|
108 | This middleware is part of the [neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) repository, a monorepo
|
109 | containing all resources for developing Neutrino and its core presets and middleware. Follow the
|
110 | [contributing guide](https://neutrino.js.org/contributing) for details.
|
111 |
|
112 | [npm-image]: https://img.shields.io/npm/v/neutrino-middleware-html-template.svg
|
113 | [npm-downloads]: https://img.shields.io/npm/dt/neutrino-middleware-html-template.svg
|
114 | [npm-url]: https://npmjs.org/package/neutrino-middleware-html-template
|
115 | [slack-image]: https://neutrino-slack.herokuapp.com/badge.svg
|
116 | [slack-url]: https://neutrino-slack.herokuapp.com/
|