1 | # Neutrino HTML Loader Middleware
|
2 |
|
3 | `@neutrinojs/html-loader` is Neutrino middleware for loading and importing HTML
|
4 | files from modules.
|
5 |
|
6 | [![NPM version][npm-image]][npm-url] [![NPM downloads][npm-downloads]][npm-url]
|
7 |
|
8 | ## Requirements
|
9 |
|
10 | - Node.js 10+
|
11 | - Yarn v1.2.1+, or npm v5.4+
|
12 | - Neutrino 9
|
13 | - webpack 4
|
14 |
|
15 | ## Installation
|
16 |
|
17 | `@neutrinojs/html-loader` can be installed via the Yarn or npm clients.
|
18 |
|
19 | #### Yarn
|
20 |
|
21 | ```bash
|
22 | ❯ yarn add --dev @neutrinojs/html-loader
|
23 | ```
|
24 |
|
25 | #### npm
|
26 |
|
27 | ```bash
|
28 | ❯ npm install --save-dev @neutrinojs/html-loader
|
29 | ```
|
30 |
|
31 | ## Usage
|
32 |
|
33 | `@neutrinojs/html-loader` can be consumed from the Neutrino API, middleware, or
|
34 | presets. Require this package and plug it into Neutrino:
|
35 |
|
36 | ```js
|
37 | const html = require('@neutrinojs/html-loader');
|
38 |
|
39 | // Use with default options
|
40 | neutrino.use(html());
|
41 |
|
42 | // Usage showing default options
|
43 | neutrino.use(
|
44 | html({
|
45 | attrs: ['img:src', 'link:href'],
|
46 | }),
|
47 | );
|
48 | ```
|
49 |
|
50 | ```js
|
51 | // Using in .neutrinorc.js
|
52 | const html = require('@neutrinojs/html-loader');
|
53 |
|
54 | // Use with default options
|
55 | module.exports = {
|
56 | use: [html()],
|
57 | };
|
58 |
|
59 | // Usage showing default options
|
60 | module.exports = {
|
61 | use: [
|
62 | html({
|
63 | attrs: ['img:src', 'link:href'],
|
64 | }),
|
65 | ],
|
66 | };
|
67 | ```
|
68 |
|
69 | The options object passed to this middleware will be passed as options to the
|
70 | html-loader used to load HTML files.
|
71 |
|
72 | ## Customization
|
73 |
|
74 | `@neutrinojs/html-loader` creates some conventions to make overriding the
|
75 | configuration easier once you are ready to make changes.
|
76 |
|
77 | ### Rules
|
78 |
|
79 | The following is a list of rules and their identifiers which can be overridden:
|
80 |
|
81 | | Name | Description | NODE_ENV |
|
82 | | ------ | -------------------------------------------------------------------------------- | -------- |
|
83 | | `html` | Allows importing HTML files from modules. Contains a single loader named `html`. | all |
|
84 |
|
85 | ## Contributing
|
86 |
|
87 | This middleware is part of the
|
88 | [neutrino](https://github.com/neutrinojs/neutrino) repository, a monorepo
|
89 | containing all resources for developing Neutrino and its core presets and
|
90 | middleware. Follow the
|
91 | [contributing guide](https://neutrinojs.org/contributing/) for details.
|
92 |
|
93 | [npm-image]: https://img.shields.io/npm/v/@neutrinojs/html-loader.svg
|
94 | [npm-downloads]: https://img.shields.io/npm/dt/@neutrinojs/html-loader.svg
|
95 | [npm-url]: https://www.npmjs.com/package/@neutrinojs/html-loader
|