# generate-asset-webpack-plugin

> A Webpack plugin for generating assets, e.g. an index.html

Latest version **0.3.0** (published 2015-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install generate-asset-webpack-plugin
pnpm add generate-asset-webpack-plugin
yarn add generate-asset-webpack-plugin
bun add generate-asset-webpack-plugin
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2015-09-17 |
| First published | 2015-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Kim Joar Bekkelund |
| Maintainers | kimjoar |
| Keywords | webpack, plugin, asset, index.html |

## Links

- npm: https://www.npmjs.com/package/generate-asset-webpack-plugin
- Repository: https://github.com/kjbekkelund/generate-asset-webpack-plugin
- Homepage: https://github.com/kjbekkelund/generate-asset-webpack-plugin#readme
- Issues: https://github.com/kjbekkelund/generate-asset-webpack-plugin/issues
- npm.io page: https://npm.io/package/generate-asset-webpack-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

- 0.3.0 (latest) — 2015-09-17
- 0.2.0 — 2015-09-17
- 0.1.0 — 2015-09-17

## README

generate-asset-webpack-plugin
=============================

Sometimes you dynamically want to create files while having access to all the
Webpack compilation info.

Install
-------

```
npm install --save-dev generate-asset-webpack-plugin
```

Usage
-----

```javascript
var GenerateAssetPlugin = require('generate-asset-webpack-plugin');

var webpackConfig = {
    plugins: [
        new GenerateAssetPlugin({
            filename: 'index.html',
            fn: (compilation, cb) => {
                cb(null, createHtml(compilation));
            },
            extraFiles: ['favicon.ico']
        })
    ]
    // other webpack config ...
}
```

Example function using the `compilation`:

```javascript
function createHtml(compilation) {
    var chunk = compilation.chunks[0];
    var jsFile = chunk.files[0];
    var cssFile = chunk.files[1];
    return `<!DOCTYPE html>
        <html>
            <head>
                <meta charset="utf-8">
                <title>Awesome!</title>
                <link rel="stylesheet" href="${cssFile}">
            </head>
            <body>
                <div id="app"></div>
                <script src="${jsFile}"></script>
            </body>
        </html>
    `;
};
```

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