# inject-chunk-webpack-plugin

> A simple Webpack plugin that inject chunks/content into html file

Latest version **2.1.0** (published 2022-01-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install inject-chunk-webpack-plugin
pnpm add inject-chunk-webpack-plugin
yarn add inject-chunk-webpack-plugin
bun add inject-chunk-webpack-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.1.0 |
| Published | 2022-01-04 |
| First published | 2021-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 49.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | bigfact |
| Maintainers | bigfact |
| Keywords | webpack, plugin, html, inject, chunk |

## Links

- npm: https://www.npmjs.com/package/inject-chunk-webpack-plugin
- Repository: https://github.com/bigfact/inject-chunk-webpack-plugin
- Homepage: https://github.com/bigfact/inject-chunk-webpack-plugin#readme
- Issues: https://github.com/bigfact/inject-chunk-webpack-plugin/issues
- npm.io page: https://npm.io/package/inject-chunk-webpack-plugin

## Dependencies (1)

- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^5.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

- 2.1.0 (latest) — 2022-01-04
- 2.0.0 — 2021-12-31
- 1.0.0 — 2021-10-22

## README

# inject-chunk-webpack-plugin

A simple Webpack plugin that inject chunks/content into html file

## Install

```
npm install inject-chunk-webpack-plugin --save-dev
```

## Usage

### 1. Add this plugin in webpack.config.js and configure it

```js
const InjectChunkWebpackPlugin = require('inject-chunk-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')

module.exports = {
  mode: 'production',
  entry: {
    app: './app.js'
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: '[name].[contenthash].js',
    publicPath: '/'
  },
  plugins: [
    new HtmlWebpackPlugin({
      filename: './index.html',
      template: path.resolve(__dirname, './src/index.html'),
      chunks: []
    }),
    new InjectChunkWebpackPlugin({
      filename: './index.html', // === HtmlWebpackPlugin filename
      content: 'var a = 1;',
      chunks: ['app'],
      startTag: '<script id="script-app">',
      endTag: '</script>'
    })
  ]
}
```

### 2. Add custom tags to the file defined in the plugin configuration

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>inject-chunk-webpack-plugin-demo</title>

    <script id="script-app"></script>
  </head>

  <body></body>
</html>
```

## LICENSE

[MIT LICENSE](./LICENSE)

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