https://github.com/hipstersmoothie/html-webpack-insert-text-plugin
Insert text into the head or body of your HTML
https://github.com/hipstersmoothie/html-webpack-insert-text-plugin
Last synced: 22 days ago
JSON representation
Insert text into the head or body of your HTML
- Host: GitHub
- URL: https://github.com/hipstersmoothie/html-webpack-insert-text-plugin
- Owner: hipstersmoothie
- License: mit
- Created: 2018-11-27T21:54:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-25T17:01:53.000Z (almost 3 years ago)
- Last Synced: 2024-10-29T08:43:10.673Z (6 months ago)
- Language: TypeScript
- Size: 288 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# html-webpack-insert-text-plugin
[](https://github.com/prettier/prettier) [](https://circleci.com/gh/hipstersmoothie/html-webpack-insert-text-plugin) [](https://www.npmjs.com/package/html-webpack-insert-text-plugin) [](https://www.npmjs.com/package/html-webpack-insert-text-plugin)
Insert text into the head or body of your HTML
## Installation
You must be running webpack 4.
```bash
npm install --save-dev html-webpack-insert-text-plugin
```## Usage
Require the plugin in your webpack config
```javascript
import HtmlWebpackInsertPlugin from 'html-webpack-insert-text-plugin';
// or
const HtmlWebpackInsertPlugin = require('html-webpack-insert-text-plugin')
.default;
```Add the plugin to your webpack config as follows
```javascript
plugins: [
new HtmlWebpackPlugin(),
new HtmlWebpackInjectPlugin([
{
target: 'index.html',
parent: 'head',
text: 'body { background: red; }'
},
{
target: 'index.html',
parent: 'body',
text: 'alert('foo')'
}
])
];
```## Structure
`html-webpack-insert-text-plugin` takes an array of configuration objects. Those object should have the following structure.
- `target` (optional): name of HTML page to target
- `parent`: parent element to add into, only can be `head` or `body`, default value is `head`
- `text`: text to insert into the `parent`