Registry / web-framework / generate-asset-webpack-plugin

generate-asset-webpack-plugin

JSON →
library0.3.0jsnpmunverified

Webpack plugin (v0.3.0) for dynamically generating asset files (like index.html) during compilation, with access to compilation info. Lightweight alternative to html-webpack-plugin with a callback-based API. Released 2015, no recent updates; works with Webpack 1-3 but not v4+. Suitable for simple HTML generation without templating.

web-framework
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Package uses CommonJS; ESM import not supported.

const GenerateAssetPlugin = require('generate-asset-webpack-plugin');

Default export only; named destructuring fails.

const GenerateAssetPlugin = require('generate-asset-webpack-plugin');

Constructor expects an options object, not separate arguments.

new GenerateAssetPlugin({ filename: 'file.txt', fn: (compilation, cb) => cb(null, 'content') })

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 })); });
Debug
Known footguns
breakingWebpack 4+ no longer supports plugins using old compilation hooks; this plugin does not work with Webpack 4+.
gotchacb must be called exactly once; failure to call cb will hang the build.
gotchaextraFiles is not well documented; files listed must exist in compilation.assets or they will be ignored.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
9 hits · last 30 days
gptbot
4
ahrefsbot
4
script
1
Resources