How to use the @open-wc/building-utils/index-html.extractResources function in @open-wc/building-utils

To help you get started, we’ve selected a few @open-wc/building-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github open-wc / open-wc / packages / rollup-plugin-index-html / src / process-entry-html.js View on Github external
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,
    },
  };
}
github open-wc / open-wc / packages / webpack-index-html-plugin / src / create-entrypoints.js View on Github external
} 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