getPublicPath(compilation, filename, customPublicPath) {
    /**
     * @type {string} the configured public path to the asset root
     * if a path publicPath is set in the current webpack config use it otherwise
     * fallback to a relative path
     */
    const webpackPublicPath = compilation.getAssetPath(
      /** @type {NonNullable<Compilation["outputOptions"]["publicPath"]>} */ (
        compilation.outputOptions.publicPath
      ),
      { hash: compilation.hash },
    );
    // Webpack 5 introduced "auto" as default value
    const isPublicPathDefined = webpackPublicPath !== "auto";

    let publicPath =
      // If the html-webpack-plugin options contain a custom public path unset it
      customPublicPath !== "auto"
        ? customPublicPath
        : isPublicPathDefined
          ? // If a hard coded public path exists use it
            webpackPublicPath
          : // If no public path was set get a relative url path
            path
              .relative(
                path.resolve(
                  /** @type {string} */ (compilation.options.output.path),
                  path.dirname(filename),
                ),
                /** @type {string} */ (compilation.options.output.path),
              )
              .split(path.sep)
              .join("/");

    if (publicPath.length && publicPath.substr(-1, 1) !== "/") {
      publicPath += "/";
    }

    return publicPath;
  }
Generate the relative or absolute base url to reference images, css, and javascript files
from within the html file - the publicPath

@private
@param {Compilation} compilation
@param {string} filename
@param {string | 'auto'} customPublicPath
@returns {string}