# html-webpack-transform-plugin

> Assets Transform extension for the HTML Webpack Plugin

Latest version **1.0.7** (published 2021-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-webpack-transform-plugin
pnpm add html-webpack-transform-plugin
yarn add html-webpack-transform-plugin
bun add html-webpack-transform-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 | 1.0.7 |
| Published | 2021-07-09 |
| First published | 2019-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | RenoFi |
| Maintainers | redmundas |
| Keywords | webpack, plugin, html, html-webpack-plugin, transform, assets |

## Links

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

- 1.0.7 (latest) — 2021-07-09
- 1.0.6 — 2021-01-04
- 1.0.5 — 2020-04-14
- 1.0.4 — 2020-03-25
- 1.0.3 — 2019-12-31
- 1.0.2 — 2019-10-14
- 1.0.1 — 2019-10-14
- 1.0.0 — 2019-10-14

## README

Assets Transform extension for the HTML Webpack Plugin
========================================

[![License](https://img.shields.io/github/license/renofi/html-webpack-transform-plugin)](https://github.com/RenoFi/html-webpack-transform-plugin/blob/master/LICENSE)
[![npm](https://img.shields.io/npm/v/html-webpack-transform-plugin)](https://www.npmjs.com/package/html-webpack-transform-plugin)
[![Build Status](https://travis-ci.org/RenoFi/html-webpack-transform-plugin.svg?branch=master)](https://travis-ci.org/RenoFi/html-webpack-transform-plugin)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FRenoFi%2Fhtml-webpack-transform-plugin.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FRenoFi%2Fhtml-webpack-transform-plugin?ref=badge_shield)


## About

This plugin will allow you to transform asset tags generated by [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin/).


## Installation

Install the plugin with npm:

```
npm i --save-dev html-webpack-transform-plugin
```

Install the plugin with yarn:

```
yarn add --dev html-webpack-transform-plugin
```


## Basic Usage

In the plugins section of your webpack config file, include the following:

```js
plugins: [
  new HtmlWebpackPlugin(),
  new HtmlWebpackTransformPlugin()
]
```


## Options

|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`attributes`**|`{Object}`|`{}`|Map of attributes to add|
|**`pathPrefix`**|`{String}`|`''`|Path prefix to use with each asset url|
|**`transform`**|`{Function}`|`tag => tag`|A callback function that is execute on each tag to allow any transformation of tags. Function must return modified tag object|
|**`replacePublicPath`**|`{Boolean}`|`false`|Used with `pathPrefix` option. If true - `publicPath` from webpack options will be replaced with `pathPrefix`|


## Examples

Add `crossorigin` attribue for each script tag:

```js
new HtmlWebpackTransformPlugin({
  attributes: {script: {crossorigin: 'anonymous'}},
}),
```

Replace public path with `ejs` template variable for dynamic paths with `expresjs`:

```js
new HtmlWebpackTransformPlugin({
  pathPrefix: '<%= assetsPath %>/',
  replacePublicPath: true,
}),
```

Do anything else with the tags using `transform` callback:

```js
new HtmlWebpackTransformPlugin({
  transform: tag => {
    // add additional properties
    // add path prefix or remove public path
    // or anything else
    return tag;
  },
}),
```


## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FRenoFi%2Fhtml-webpack-transform-plugin.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FRenoFi%2Fhtml-webpack-transform-plugin?ref=badge_large)

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