Skip to content

A Webpack plugin to resolve ESI includes

Notifications You must be signed in to change notification settings

jodelamo/esi-webpack-plugin

Repository files navigation

esi-webpack-plugin

A Webpack plugin to resolve ESI includes.

Useful in development in conjunction with html-webpack-plugin to resolve ESI includes (using nodesi) in all emitted HTML files.

Install

npm install --save-dev esi-webpack-plugin

Usage

Options map more or less directly to the options provided by nodesi:

import HtmlWebpackPlugin from "html-webpack-plugin"
import EsiWebpackPlugin from "esi-webpack-plugin"

export default {
  // ...
  plugins: [
    new HtmlWebpackPlugin(),
    new EsiWebpackPlugin({
      baseUrl: "https://example.com",
      // Note: `baseUrl` is automatically added to `allowedHosts`
      allowedHosts: [
        "https://some-other-host.com",
      ]
      onError(src, err) {
        console.error(`Error when resolving ${src}: ${err}`)
      },
      processOptions: {
        headers: {
          Authorization: "Basic Zm9vOmJhcgo=",
        },
      },
    }),
  ],
}

License

MIT