Skip to content

fwm227/html-middleware-webpack-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

html-middleware-webpack-plugin

This is flexible middle plugin to processing your html when html-webpack-plugin processing source, and this plugin can use in webpack@5 environment.

how to use

const HtmlMiddlewareWebpackPlugin = require('html-middleware-webpack-plugin');

plugins: [
  new HtmlWebpackPlugin(),
  new HtmlMiddlewareWebpackPlugin({
    // to hint resource
    resourceHint: {
      'dns-prefetch': [String], // e.g. 'dns-prefetch': ['https://xxx', ...]
      'preconnnect': [String],
      'prefetch': [String],
      'preload': [String],
      'prerender': [String]
    },
    // insert script into body
    scripts: [{
      src: url,
      async: Boolean,
      defer: Boolean
    }],
    // custom tag
    customTags: {
      // insert head
      headTags: [{
        tagName: String,
        voidTag: Boolean,
        attributes: {
          href: String,
          ...
        }
      }],
      // insert body
      bodyTags: [{
        tagName: String,
        voidTag: Boolean,
        attributes: {
          src: String,
          ...
        }
      }]
    }
  })
]

License

MIT

Copyright (c) 2020-present, fwm227

About

the middle handler of html-webpack-plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published