@web/rollup-plugin-html
Version:
Rollup plugin for bundling HTML files
39 lines • 1.72 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.createHTMLOutput = exports.createHTMLAsset = void 0;
const getEntrypointBundles_js_1 = require("./getEntrypointBundles.js");
const getOutputHTML_js_1 = require("./getOutputHTML.js");
const utils_js_1 = require("../utils.js");
async function createHTMLAsset(params) {
const { outputDir, input, emittedAssets, generatedBundles, externalTransformHtmlFns, pluginOptions, defaultInjectDisabled, serviceWorkerPath, injectServiceWorker, absolutePathPrefix, strictCSPInlineScripts, } = params;
if (generatedBundles.length === 0) {
throw (0, utils_js_1.createError)('Cannot output HTML when no bundles have been generated');
}
const entrypointBundles = (0, getEntrypointBundles_js_1.getEntrypointBundles)({
pluginOptions,
generatedBundles,
inputModuleIds: input.moduleImports,
outputDir,
htmlFileName: input.name,
});
const outputHtml = await (0, getOutputHTML_js_1.getOutputHTML)({
pluginOptions,
entrypointBundles,
input,
outputDir,
emittedAssets,
externalTransformHtmlFns,
defaultInjectDisabled,
serviceWorkerPath,
injectServiceWorker,
absolutePathPrefix,
strictCSPInlineScripts,
});
return { fileName: input.name, name: input.name, source: outputHtml, type: 'asset' };
}
exports.createHTMLAsset = createHTMLAsset;
async function createHTMLOutput(params) {
return Promise.all(params.inputs.map(input => createHTMLAsset(Object.assign(Object.assign({}, params), { input }))));
}
exports.createHTMLOutput = createHTMLOutput;
//# sourceMappingURL=createHTMLOutput.js.map
;