Skip to content

Alter the HTML file programatically that html-webpack-plugin generates

License

Notifications You must be signed in to change notification settings

BlueOakJS/html-webpack-alter-html-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Alter the HTML file programatically that html-webpack-plugin generates

Enhances 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 plugin 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:

$ npm install --save-dev html-webpack-alter-html-plugin

Basic Usage

Require the plugin in your webpack config:

var HtmlWebpackAlterHtmlPlugin = require('html-webpack-alter-html-plugin');

Add the plugin to your webpack config as follows:

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:

function alterHTML(html) {
	var $ = cheerio.load(html, {
		decodeEntities: false
	});
	
	// Alter the HTML.

	return $.html();
}

This plugin is based on html-webpack-harddisk-plugin.

License

Copyright (c) 2017 PointSource, LLC. MIT Licensed.

About

Alter the HTML file programatically that html-webpack-plugin generates

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published