How to use the @open-wc/building-utils/index-html.createIndexHTML 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 / create-output.js View on Github external
function injectIntoIndexHTML(pluginConfig, inputIndexHTML, entries, legacyEntries) {
  /**
   * Inject output files, loader script and polyfills into index.html
   */
  if (pluginConfig.inject) {
    const result = createIndexHTML(inputIndexHTML, {
      ...pluginConfig,
      entries,
      legacyEntries,
    });

    return [{ path: pluginConfig.indexFilename, content: result.indexHTML }, ...result.files];
  }

  /**
   * If injection is disabled the user takes control, probably with it's own template.
   */
  const serialized = serialize(inputIndexHTML);
  return [{ path: pluginConfig.indexFilename, content: minifyIndexHTML(serialized) }];
}
github open-wc / open-wc / packages / webpack-index-html-plugin / src / emit-index-html.js View on Github external
});
      localBaseIndex = parse(templateString);
    } else {
      /**
       * If there is no user defined template the entrypoint was an index.html, and we use that as the base
       * for our output. We need to clone it to avoid mutating the baseIndex variable.
       */
      localBaseIndex = cloneAST(baseIndex);
    }

    /** @type {string} */
    let finalIndexHTML;

    /** Inject generated output into index.html */
    if (config.inject) {
      const generateResult = createIndexHTML(localBaseIndex, {
        ...config,
        entries: { type: 'script', files: entries },
        legacyEntries: legacyEntries ? { type: 'script', files: legacyEntries } : undefined,
      });

      finalIndexHTML = generateResult.indexHTML;
      if (config.multiIndex && config.multiIndex.transformIndex) {
        finalIndexHTML = config.multiIndex.transformIndex(
          finalIndexHTML,
          variation.toString(),
          variation === VARIATION_FALLBACK,
        );
      }

      generateResult.files.forEach(file => {
        compilation.assets[file.path] = {