Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function processEntryHtml(inputConfig) {
if (typeof inputConfig.input !== 'string' || !inputConfig.input.endsWith('index.html')) {
throw createError('Input must be an index.html file, or an indexHTML option must be provided.');
}
const indexFolder = path.dirname(inputConfig.input);
const indexHTMLString = fs.readFileSync(inputConfig.input, 'utf-8');
const {
jsModules,
inlineModules,
inlineImportMaps,
indexHTML: outputIndexHTML,
} = extractResources(indexHTMLString);
const input = [
...jsModules.map(joinTo(indexFolder)),
...inlineModules.map(createInlineModule(indexFolder)),
];
return {
outputIndexHTML,
inlineImportMaps,
inlineModules,
rollupOptions: {
...inputConfig,
input,
},
};
}
} else {
if (!entry.endsWith('index.html')) {
throw createError(
'Entry must be a single index.html file. If you wish to use a javascript file as entrypoint you need to set a HTML template function.',
);
}
index = entry;
}
if (!fs.existsSync(index)) {
throw createError(`Could not find entry file: ${index}`);
}
const indexFolder = path.dirname(index);
const indexHTMLString = fs.readFileSync(index, 'utf-8');
const resources = extractResources(indexHTMLString);
if (resources.jsModules.length === 0) {
throw createError(
'Could not find any js modules in entry point. Add a