{"version":3,"sources":["jsdelivr-header.js","/npm/thymeleaf-inject-webpack-plugin@0.0.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAEA,MAAM,OAAS,QAAQ,UACjB,aAAe,QAAQ,iBAEvB,OAAS,+BACT,MAAQ,uCAEd,MAAM,6BACJ,WAAA,CAAa,GACX,OAAO,MAAM,OAAS,EAAW,+DACnC,CAEA,KAAA,CAAO,GAED,EAAS,MAEX,EAAS,MAAM,YAAY,IAAI,QAAQ,IACjC,EAAY,MAAM,iCACpB,EAAY,MAAM,gCAAgC,SAAS,OACzD,KAAK,2CAA2C,KAAK,MAEzD,IAIF,EAAS,OAAO,eAAe,IAC7B,EAAY,OAAO,MACjB,KAAK,2CAA2C,KAAK,MACtD,GAGP,CAKA,0CAAA,CAA4C,EAAgB,GACzB,EAAe,OAAO,QAAvD,MACM,EAAa,aAAa,CAAC,EAAG,GAEpC,EAAW,KAAK,QAAQ,KAAK,sBAC7B,EAAW,KAAK,QAAQ,KAAK,sBAE7B,EAAS,KAAM,EACjB,CAEA,oBAAA,CAAsB,GACpB,OAAQ,EAAc,SACpB,IAAK,SAEkC,mBAAjC,EAAc,WAAW,OAC3B,EAAc,WAAW,UAAY,KAAO,EAAc,WAAW,IAAM,KAE7E,MACF,IAAK,OAEiC,cAAhC,EAAc,WAAW,MAC3B,EAAc,WAAW,WAAa,KAAO,EAAc,WAAW,KAAO,KAOnF,OAAO,CACT,EAGF,OAAO,QAAU","file":"/npm/thymeleaf-inject-webpack-plugin@0.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/thymeleaf-inject-webpack-plugin@0.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict';\n\nconst assert = require('assert')\nconst objectAssign = require('object-assign')\n\nconst PLUGIN = 'ThymeleafInjectWebpackPlugin'\nconst EVENT = 'html-webpack-plugin-alter-asset-tags'\n\nclass ThymeleafInjectWebpackPlugin {\n  constructor (options) {\n    assert.equal(options, undefined, 'The ThymeleafInjectWebpackPlugin does not accept any options');\n  }\n\n  apply (compiler) {\n    // Hook into the html-webpack-plugin processing\n    if (compiler.hooks) {\n      // Webpack 4+ Plugin System\n      compiler.hooks.compilation.tap(PLUGIN, compilation => {\n        if (compilation.hooks.htmlWebpackPluginAlterAssetTags) {\n          compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync(PLUGIN,\n            this.thymeleafInjectWebpackPluginAlterAssetTags.bind(this)\n          );\n        }\n      });\n    } else {\n      // Webpack 1-3 Plugin System\n      compiler.plugin('compilation', compilation => {\n        compilation.plugin(EVENT,\n          this.thymeleafInjectWebpackPluginAlterAssetTags.bind(this)\n        );\n      });\n    }\n  }\n\n  /**\n   * The main processing function\n   */\n  thymeleafInjectWebpackPluginAlterAssetTags (htmlPluginData, callback) {\n    const htmlWebpackPluginOptions = htmlPluginData.plugin.options;\n    const pluginData = objectAssign({}, htmlPluginData);\n\n    pluginData.body.forEach(this.appendThymeLeafAttrs);\n    pluginData.head.forEach(this.appendThymeLeafAttrs);\n\n    callback(null, pluginData);\n  }\n\n  appendThymeLeafAttrs (tagDefinition) {\n    switch (tagDefinition.tagName) {\n      case 'script':\n        // JS file\n        if (tagDefinition.attributes.type == 'text/javascript') {\n          tagDefinition.attributes['th:src'] = \"@{\" + tagDefinition.attributes.src + \"}\"\n        }\n        break;\n      case 'link':\n        // CSS file\n        if (tagDefinition.attributes.rel == 'stylesheet') {\n          tagDefinition.attributes['th:href'] = \"@{\" + tagDefinition.attributes.href + \"}\"\n        }\n        break;\n      default:\n        // do nothing\n    }\n\n    return tagDefinition\n  }\n}\n\nmodule.exports = ThymeleafInjectWebpackPlugin\n"]}