A webpack plugin that automatically adds preload or prefetch links for font assets to the HTML output, improving page load performance by prioritizing font loading. Current stable version is 1.5.0, with a 2.0.0-beta.0 release in development. Release cadence is irregular. Key differentiators: zero-config for most webpack setups, supports both webpack 4 and 5, provides filtering and custom HTML replacement callbacks. Built-in TypeScript types since v1.4.0. Requires jsdom and webpack-sources as dependencies.
npm install webpack-font-preload-pluginVerified import paths — ran on the pinned version, not inferred.
Basic webpack configuration to preload font files. Shows plugin setup with HtmlWebpackPlugin, file-loader for fonts, and preload option.
If using TypeScript, import the default export as described. No further changes needed.
Run npm install jsdom to add it explicitly if not included by npm automatically.
Add new HtmlWebpackPlugin() to your webpack plugins array.
Upgrade to v1.4.1 or later, or ensure publicPath is a non-empty string.
Upgrade to version 2.0.0-beta.0 or later, or use a hook shim. Alternatively, stick with webpack 4.
Upgrade to v1.4.1+ or use the correct instantiation: new WebpackFontPreloadPlugin() without extra options.
Install jsdom: npm install jsdom --save-dev