UNPKG

html-webpack-plugin-inject-thyme-leaf-tags

Version:

A html webpack plugin to inject thymeleaf compatible template tags for script and style tags

2 lines (1 loc) 1.74 kB
var b=Object.create;var r=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames,c=Object.getOwnPropertySymbols,P=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var f=t=>r(t,"__esModule",{value:!0});var u=(t,i)=>{var s={};for(var e in t)p.call(t,e)&&i.indexOf(e)<0&&(s[e]=t[e]);if(t!=null&&c)for(var e of c(t))i.indexOf(e)<0&&x.call(t,e)&&(s[e]=t[e]);return s};var d=(t,i)=>{for(var s in i)r(t,s,{get:i[s],enumerable:!0})},h=(t,i,s,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of g(i))!p.call(t,n)&&(s||n!=="default")&&r(t,n,{get:()=>i[n],enumerable:!(e=m(i,n))||e.enumerable});return t},j=(t,i)=>h(f(r(t!=null?b(P(t)):{},"default",!i&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),k=(t=>(i,s)=>t&&t.get(i)||(s=h(f({}),i,1),t&&t.set(i,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var $={};d($,{default:()=>H});var y=j(require("html-webpack-plugin"));function o(t={}){this.options=t,this.PluginName="HtmlWebpackPluginInjectThymeLeafTags"}o.prototype.apply=function(t){t.hooks.thisCompilation.tap(this.PluginName,i=>{var s=this;y.default.getHooks(i).afterTemplateExecution.tapAsync(this.PluginName,(e,n)=>{let{headTags:l,bodyTags:T}=e;l.forEach(function(a){s.injectTags(a)}),T.forEach(function(a){s.injectTags(a)}),n(null,e)})})};o.prototype.injectTags=function(t){t.attributes.src&&(t.attributes["th:src"]=`@{${this.options.scriptPrefix}${t.attributes.src}}`),t.attributes.href&&(t.attributes["th:href"]=`@{${this.options.scriptPrefix}${t.attributes.href}}`);let n=t.attributes,{src:i,href:s}=n,e=u(n,["src","href"]);return t.attributes=e,t};var H=o;module.exports=k($);0&&(module.exports={});