UNPKG

inject-body-webpack-plugin

Version:

Webpack plugin that injects a custom string into the body of the html-webpack-plugin output.

8 lines 1.64 kB
/*! *** inject-body-webpack-plugin 1.3.0 *** Copyright © 2021, Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid) *** @license MIT *** See https://github.com/Jaid/inject-body-webpack-plugin !*/ var e,t;e=global,t=function(){return(()=>{var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:()=>c});const o=require("html-webpack-plugin");var n=e.n(o);const i=require("insert-string-after");var r=e.n(i);const p=require("insert-string-before");var a=e.n(p);const s=require("debug"),l=e.n(s)()("inject-body-webpack-plugin");class c{constructor(e){this.options={content:"<div id=root/>",position:"start",...e}}apply(e){l("Options: %o",this.options),e.hooks.compilation.tap("inject-body-webpack-plugin",(e=>{l("tap: compilation"),n().getHooks(e).beforeEmit.tap("inject-body-webpack-plugin",(e=>{l("tap: html-webpack-plugin beforeEmit"),l("Before: %s",e.html),e.html="end"===this.options.position?a()(e.html,"</body>",this.options.content):r()(e.html,"<body>",this.options.content),l("After: %s",e.html)}))}))}}return t})()},"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["inject-body-webpack-plugin"]=t():e.InjectBodyWebpackPlugin=t(); //# sourceMappingURL=index.js.map