# html-add-attr-webpack-plugin

> 为生成的html文件中标签添加属性

Latest version **1.0.1** (published 2019-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install html-add-attr-webpack-plugin
pnpm add html-add-attr-webpack-plugin
yarn add html-add-attr-webpack-plugin
bun add html-add-attr-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 | 1.0.1 |
| Published | 2019-11-18 |
| First published | 2019-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 2.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | AnotherSola |
| Maintainers | anothersola |
| Keywords | webpack, plugin, html, template |

## Links

- npm: https://www.npmjs.com/package/html-add-attr-webpack-plugin
- Repository: https://github.com/anotherso1a/html-add-attr-webpack-plugin
- Homepage: https://github.com/anotherso1a/html-add-attr-webpack-plugin#readme
- Issues: https://github.com/anotherso1a/html-add-attr-webpack-plugin/issues
- npm.io page: https://npm.io/package/html-add-attr-webpack-plugin

## Dependencies (1)

- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.3

## 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.1 (latest) — 2019-11-18
- 1.0.0 — 2019-11-18

## README

# HtmlAddAttrWebpackPlugin

## Usage

### Install

```sh
npm install html-add-attr-webpack-plugin -D
```

### Example

for SPA (single-page-application):

```js
//webpack.config.js
module.exports = {
  plugin: [
    //...other options
    new HtmlAddAttrWebpackPlugin({
      attrs: {
        'script': {
          crossOrigin: 'anonymous'
        }
      }
    })
  ]
}//will add crossOrigin="anonymous" to script tag.
```

for multi-page application:

```js
//webpack.config.js
module.exports = {
  plugin: [
    //...other options
    new HtmlAddAttrWebpackPlugin([{
      attrs: {
        'script': {
          crossOrigin: 'anonymous'
        }
      } //will rewrite index.html
    }, {
      sourceFile: 'sub.html',
      attrs: {
        'link': {
          class: 'link'
        },
        'script': {
          class: 'sub'
        }
      } //will rewrite sub.html
    }])
  ]
}
```

### Options

|props|description|
|:-:|:-:|
|sourceFile|the html file that needs to rewrite. (default 'index.html')|
|attrs|just like html attributes|

tks for using

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