function PrerenderLoader (content) {
  const options = loaderUtils.getOptions(this) || {};
  const outputFilter = options.as === 'string' || options.string ? stringToModule : String;

  if (options.disabled === true) {
    return outputFilter(content);
  }

  // When applied to HTML, attempts to inject into a specified {{prerender}} field.
  // @note: this is only used when the entry module exports a String or function
  // that resolves to a String, otherwise the whole document is serialized.
  let inject = false;
  if (!this.request.match(/\.(js|ts)x?$/i)) {
    const matches = content.match(PRERENDER_REG);
    if (matches) {
      inject = true;
      options.entry = matches[1];
    }
    options.templateContent = content;
  }

  const callback = this.async();

  prerender(this._compilation, this.request, options, inject, this)
    .then(output => {
      callback(null, outputFilter(output));
    })
    .catch(err => {
      // console.error(err);
      callback(err);
    });
}
prerender-loader can be applied to any HTML or JS file with the given options.
@public
@param {Options} options Options to control how Critters inlines CSS.

@example
// webpack.config.js
module.exports = {
  plugins: [
    new HtmlWebpackPlugin({
      // `!!` tells webpack to skip any configured loaders for .html files
      // `?string` tells prerender-loader output a JS module exporting the HTML string
      template: '!!prerender-loader?string!index.html'
    })
  ]
}

@example
// inline demo: assumes you have html-loader set up:
import prerenderedHtml from '!prerender-loader!./file.html';