Awesome Open Source
Awesome Open Source

html-webpack-processing-plugin

npm NPM Build Status

HTML pre-processing and post-processing for html-webpack-plugin. It supports webpack v4.

Installation

npm install html-webpack-processing-plugin

Usage

  • add pre-processor
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackProcessingPlugin = require("html-webpack-processing-plugin");

const webpackConfig = {
  entry: "index.js",
  output: {
    path: "dist",
    filename: "index_bundle.js",
  },
  plugins: [
    new HtmlWebpackPlugin({
      preProcessing: (originalHTML) => {
        let newHTML = originalHTML + "<div></div>";
        return newHTML;
      },
    }),
    new HtmlWebpackProcessingPlugin(),
  ],
};
  • add post-processor
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackProcessingPlugin = require('html-webpack-processing-plugin';)

const webpackConfig = {
  entry: 'index.js',
  output: {
    path: 'dist',
    filename: 'index_bundle.js'
  },
  plugins: [
    new HtmlWebpackPlugin({
      postProcessing: originalHTML => {
        let newHTML = originalHTML + '<div></div>';
        return newHTML;
      }
    }),
    new HtmlWebpackProcessingPlugin()
  ]
};

License

This project is licensed under MIT.

Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,072,185
Html (245,885
Plugin (113,719
Webpack (23,677
Processing (13,289
Post Processing (404
Html Webpack Plugin (141