https://github.com/best-shot/html-add-asset-webpack-plugin
Webpack plugin to inject tags to html
https://github.com/best-shot/html-add-asset-webpack-plugin
cdn html html-webpack-plugin plugin script style webpack webpack-plugin
Last synced: 4 months ago
JSON representation
Webpack plugin to inject tags to html
- Host: GitHub
- URL: https://github.com/best-shot/html-add-asset-webpack-plugin
- Owner: best-shot
- Created: 2022-03-29T03:18:55.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T06:33:36.000Z (almost 2 years ago)
- Last Synced: 2025-02-26T06:04:34.903Z (11 months ago)
- Topics: cdn, html, html-webpack-plugin, plugin, script, style, webpack, webpack-plugin
- Language: TypeScript
- Homepage:
- Size: 393 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# html-add-asset-webpack-plugin
Webpack plugin to inject tags to html.
[![npm][npm-badge]][npm-url]
[![github][github-badge]][github-url]
![node][node-badge]
[npm-url]: https://www.npmjs.com/package/html-add-asset-webpack-plugin
[npm-badge]: https://img.shields.io/npm/v/html-add-asset-webpack-plugin.svg?style=flat-square&logo=npm
[github-url]: https://github.com/best-shot/html-add-asset-webpack-plugin
[github-badge]: https://img.shields.io/npm/l/html-add-asset-webpack-plugin.svg?style=flat-square&colorB=blue&logo=github
[node-badge]: https://img.shields.io/node/v/html-add-asset-webpack-plugin.svg?style=flat-square&colorB=green&logo=node.js
## Installation
```bash
npm install html-add-asset-webpack-plugin --save-dev
```
## Usage
Add the plugin to your webpack config
```javascript
import { HtmlAddAssetWebpackPlugin } from 'html-add-asset-webpack-plugin';
// or
const { HtmlAddAssetWebpackPlugin } = require('html-add-asset-webpack-plugin');
```
```javascript
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html'
}),
new HtmlWebpackPlugin({
filename: 'other.html',
tags: [
'simple.js',
{
tagName: 'script',
prepend: true,
attributes: {
src: 'special-script.js'
}
}
]
}),
new HtmlAddAssetWebpackPlugin()
];
```
To:
```html
```
## Options
### HtmlWebpackPlugin.Options.tags:
```ts
interface Tag extends Omit {
voidTag?: boolean;
prepend?: boolean;
tagName: 'meta' | 'script' | 'style' | 'link';
}
type tags = (string | Tag)[];
```
## Inspiration
This project is inspired by [html-webpack-inject-plugin](https://github.com/kagawagao/html-webpack-inject-plugin).