https://github.com/blueoakjs/html-webpack-alter-html-plugin
Alter the HTML file programatically that html-webpack-plugin generates
https://github.com/blueoakjs/html-webpack-alter-html-plugin
Last synced: about 1 year ago
JSON representation
Alter the HTML file programatically that html-webpack-plugin generates
- Host: GitHub
- URL: https://github.com/blueoakjs/html-webpack-alter-html-plugin
- Owner: BlueOakJS
- License: mit
- Created: 2017-04-11T20:20:01.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-11T20:35:08.000Z (about 9 years ago)
- Last Synced: 2025-01-18T05:28:00.678Z (over 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Alter the HTML file programatically that html-webpack-plugin generates
Enhances [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin)
functionality by allowing a webpack build to specify a function that alters the generated HTML.
This is an extension plugin for the [webpack](http://webpack.github.io) plugin [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin) - a plugin that simplifies the creation of HTML files to serve your webpack bundles.
Installation
------------
You must be running webpack on node 6.x or higher
Install the plugin with npm:
```shell
$ npm install --save-dev html-webpack-alter-html-plugin
```
Basic Usage
-----------
Require the plugin in your webpack config:
```javascript
var HtmlWebpackAlterHtmlPlugin = require('html-webpack-alter-html-plugin');
```
Add the plugin to your webpack config as follows:
```javascript
plugins: [
new HtmlWebpackPlugin(),
new HtmlWebpackAlterHtmlPlugin(alterHTML)
]
```
`alterHTML` is a function that will be called during build with the HTML file generated by html-webpack-plugin. You can alter the HTML in the function and return the updated string. For example:
```javascript
function alterHTML(html) {
var $ = cheerio.load(html, {
decodeEntities: false
});
// Alter the HTML.
return $.html();
}
```
This plugin is based on [html-webpack-harddisk-plugin](https://github.com/jantimon/html-webpack-harddisk-plugin).
# License
Copyright (c) 2017 PointSource, LLC. MIT Licensed.