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AAO,OAAO,EAAM,EAAO,GAAO,GAAU,GACrH,GACJ,GACJ,EAER,CAEA,OAAO,QAAU","file":"/npm/rollup-plugin-html-bundle@0.0.3/dist/rollup-plugin-html-bundle.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/rollup-plugin-html-bundle@0.0.3/dist/rollup-plugin-html-bundle.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\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar fs = _interopDefault(require('fs'));\nvar path = _interopDefault(require('path'));\n\n/**\r\n * Generates a html file from a template that either has the bundle included using a script-tag with src or inlined in a script-tag.\r\n * Will by default use a script-tag with src and place a query string with v = Date.now() at the end of the path, to avoid using a cached bundle.js in dev.\r\n * @param {Object} userOptions The options object.\r\n * @return {Object} The rollup code object.\r\n */\r\nfunction bundle(userOptions) {\n    if ( userOptions === void 0 ) userOptions = {};\n\r\n    var options = {\r\n        template: 'src/template.html',\r\n        target: 'dist/index.html',\r\n        targetElement: 'body',\r\n        timestamp: true,\r\n        inline: false,\r\n        async: false,\r\n        defer: false\r\n    };\r\n    Object.assign(options, userOptions);\r\n    return {\r\n        name: 'html-bundle',\r\n        generateBundle: function (outputOptions, bundle, isWrite) {\r\n            return new Promise(function (accept, reject) {\r\n                if (!isWrite) { return accept(); }\r\n                var attr = '', inject = '';\r\n                if (options.async) { attr += ' async'; }\r\n                if (options.defer) { attr += ' defer'; }\r\n\r\n                fs.readFile(path.resolve(options.template), 'utf8', function (err, templateContent) {\r\n                    if (err) { return reject(err); }\r\n\r\n                    var targetIndex = templateContent.lastIndexOf((\"</\" + (options.targetElement) + \">\"));\r\n                    if (targetIndex === -1)\r\n                        { return reject(\"invalid targetElement\"); }\r\n\r\n                    Object.values(bundle).forEach(function (module) {\r\n                        if (err) {\r\n                            reject(err);\r\n                            throw err;\r\n                        }\r\n\r\n                        if (options.inline) {\r\n                            inject += \"<script\" + attr + \">\\n\" + (module.code) + \"</script>\\n\";\r\n                        }\r\n\r\n                        else {\r\n                            var src = path.basename(module.fileName) + (options.timestamp ? (\"?v=\" + (Date.now())) : '');\r\n                            inject += \"<script\" + attr + \" src=\\\"\" + src + \"\\\"></script>\\n\";\r\n                        }\r\n                    });\r\n\r\n                    var bundledContent = templateContent.substr(0, targetIndex) + inject + templateContent.substr(targetIndex);\r\n                    fs.writeFile(path.resolve(options.target), bundledContent, function (err) { return err ? reject(err) : accept(); });\r\n                });\r\n            })\r\n        },\r\n    };\r\n}\n\nmodule.exports = bundle;\n"]}