Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
WebfontPlugin
✓ import WebfontPlugin from 'webfont-webpack-plugin'
✗ const WebfontPlugin = require('webfont-webpack-plugin')
Default import (ESM) is correct. CommonJS require works but is deprecated in favor of ESM.
WebfontPlugin
✓ const WebfontPlugin = require('webfont-webpack-plugin').default
✗ const WebfontPlugin = require('webfont-webpack-plugin')
In CommonJS, default export is under .default. The direct require gives an object { default: ... }.
WebfontPlugin
✓ import WebfontPlugin from 'webfont-webpack-plugin'
✗ import { WebfontPlugin } from 'webfont-webpack-plugin'
It's a default export, not a named export.
Minimal configuration for generating icon fonts from SVG files using WebfontPlugin.
// webpack.config.js
import WebfontPlugin from 'webfont-webpack-plugin';
import path from 'path';
export default {
entry: path.resolve(__dirname, 'src/index.js'),
output: {
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.(svg|eot|ttf|woff|woff2)$/, use: ['url-loader'] },
],
},
plugins: [
new WebfontPlugin({
files: path.resolve(__dirname, 'icons/**/*.svg'),
dest: path.resolve(__dirname, 'dist/fonts'),
destTemplate: path.resolve(__dirname, 'dist'),
fontName: 'myfont',
formats: ['ttf', 'woff', 'woff2'],
templateOptions: {
classPrefix: 'icon-',
baseSelector: '.icon',
},
}),
],
};
Errors
Common errors & fixes
TypeError: WebfontPlugin is not a constructor
Using incorrect import/require pattern (e.g., named import or direct require without .default).
fixUse import WebfontPlugin from 'webfont-webpack-plugin' or const WebfontPlugin = require('webfont-webpack-plugin').default Cannot find module 'webfont-webpack-plugin'
Package not installed.
fixnpm install --save-dev webfont-webpack-plugin
Error: The 'files' option is required
Missing 'files' option in plugin configuration.
fixProvide a glob pattern string or array for 'files'.
Audit
Dependencies
webpackrequiredpeer dependency - plugin interfaces with webpack's compilation and watch system
watchpackrequiredpeer dependency - used for file watching in older versions