# html-inject-plugin

> html inject plugin

Latest version **2.0.4** (published 2020-10-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-inject-plugin
pnpm add html-inject-plugin
yarn add html-inject-plugin
bun add html-inject-plugin
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2020-10-27 |
| First published | 2018-09-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Yi-love |
| Maintainers | cray |
| Keywords | html, inject, webpack, plugin |

## Links

- npm: https://www.npmjs.com/package/html-inject-plugin
- Repository: https://github.com/Yi-love/html-inject-plugin
- Homepage: https://github.com/Yi-love/html-inject-plugin#readme
- Issues: https://github.com/Yi-love/html-inject-plugin/issues
- npm.io page: https://npm.io/package/html-inject-plugin

## 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

- 2.0.4 (latest) — 2020-10-27
- 2.0.3 — 2020-10-27
- 2.0.2 — 2020-10-27
- 2.0.1 — 2020-10-26
- 2.0.0 — 2020-10-26
- 1.0.6 — 2018-12-19
- 1.0.5 — 2018-12-19
- 1.0.4 — 2018-12-13
- 1.0.3 — 2018-09-28
- 1.0.2 — 2018-09-21
- 1.0.1 — 2018-09-21

## README

# Html-inject-plugin
inject `<link>` and `<script>` to output file.  this is a webpack4 plugin.

## npm
```
npm install --save-dev html-inject-plugin
```

## use

```js
new HtmlInjectPlugin({
    filename: 'test.html',
    chunks:['vue' , 'test'],
    jsOptions: {
        vue: ['rel="preload"', 'crossorigin="anonymous"'],
        test: ['crossorigin="anonymous"']
    },
    cssOptions: ['rel="preload"', 'crossorigin="anonymous"'],
    template: path.resolve(__dirname , 'template.html')
});
```

### params

* filename
* chunks
* template

```html
//template.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
    <!-- inject:preload -->
    <!-- inject:css -->
</head>
<body>
    <div class="body-wrapper">
       <div id="headerApp">header</div>
        <div class="main-wrapper">
            <div id="sidebarApp">sidebar</div>
            <div class="main-container">
            </div>
        </div>
        <div id="footerApp">footer</div> 
    </div>
    <!-- inject:js -->
</body>
</html>
```

## synx

* entry  入口文件的名称 

```
<!-- inject:(css|js)(:entry?) -->
```

## output file

```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><%=title%></title>
    <link ref="preload" rel="stylesheet" href="http:/www.test.com/dist/test.css?v=18c16ad2a2132b655533" as="style" crossorigin="anonymous" />
    <link ref="preload" rel="stylesheet" href="http:/www.test.com/dist/vue.js?v=2981d8bb85bde7e5ce33" as="script" crossorigin="anonymous" />
    <!-- inject:preload -->

    <link rel="stylesheet" href="http:/www.test.com/dist/test.css?v=18c16ad2a2132b655533" crossorigin="anonymous"/>
    <!-- inject:css -->
</head>
<body>
    <div class="body-wrapper">
       <div id="headerApp">header</div>
        <div class="main-wrapper">
            <div id="sidebarApp">sidebar</div>
            <div class="main-container">
                <%=render.content%>
            </div>
        </div>
        <div id="footerApp">footer</div> 
    </div>
    <script crossorigin="anonymous" defer src="http:/www.test.com/dist/vue.js?v=2981d8bb85bde7e5ce33" ></script>
    <script crossorigin="anonymous" defer src="http:/www.test.com/dist/test.js?v=2981d8bb85bde7e5ce33"></script>
<!-- inject:js -->
</body>
</html>
```

## error

`html-loader`.

```
You may need an appropriate loader to handle this file type.
```

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