Registry /
web-framework / generate-asset-webpack-plugin
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.
GenerateAssetPlugin
✓ const GenerateAssetPlugin = require('generate-asset-webpack-plugin');
✗ import GenerateAssetPlugin from 'generate-asset-webpack-plugin';
Package uses CommonJS; ESM import not supported.
default
✓ const GenerateAssetPlugin = require('generate-asset-webpack-plugin');
✗ const { GenerateAssetPlugin } = require('generate-asset-webpack-plugin');
Default export only; named destructuring fails.
new GenerateAssetPlugin({...})
✓ new GenerateAssetPlugin({ filename: 'file.txt', fn: (compilation, cb) => cb(null, 'content') })
✗ new GenerateAssetPlugin('file.txt', (compilation, cb) => cb(null, 'content'))
Constructor expects an options object, not separate arguments.
Shows creating a Webpack config that generates an index.html as an asset, using the plugin's callback API.
const GenerateAssetPlugin = require('generate-asset-webpack-plugin');
const webpack = require('webpack');
const compiler = webpack({
entry: './src/index.js',
output: { path: './dist', filename: 'bundle.js' },
plugins: [
new GenerateAssetPlugin({
filename: 'index.html',
fn: (compilation, cb) => {
const chunk = compilation.chunks[0];
const jsFile = chunk.files[0];
const html = `<!DOCTYPE html><html><head><title>App</title></head><body><script src="${jsFile}"></script></body></html>`;
cb(null, html);
},
extraFiles: ['favicon.ico']
})
]
});
compiler.run((err, stats) => {
if (err) console.error(err);
console.log(stats.toString({ colors: true }));
});
Errors
Common errors & fixes
TypeError: GenerateAssetPlugin is not a constructor
Incorrect import: destructured instead of default require.
fixUse const GenerateAssetPlugin = require('generate-asset-webpack-plugin'); Error: Cannot find module 'generate-asset-webpack-plugin'
Package not installed or typo in package name.
fixRun npm install --save-dev generate-asset-webpack-plugin and check node_modules.
Audit
Dependencies
webpackrequiredpeer dependency; plugin is designed to work as a Webpack plugin