Registry / devops / generate-file-webpack-plugin

generate-file-webpack-plugin

JSON →
library1.0.1jsnpmunverified

A general-purpose Webpack plugin (v1.0.1) for generating arbitrary files during the build process. Supports file paths (relative or absolute), content as strings, Buffers, Promises, or functions returning these. Works with Webpack 4.x (5.x untested) and Node.js 12+. Features include debug mode with console output. Less opinionated than similar plugins like `webpack-manifest-plugin` or `html-webpack-plugin`, allowing any file content generation. Last updated in 2020, currently in maintenance mode with no active development.

devops
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 provides a CommonJS default export (function). There is no named export. Using ES import syntax fails in strict ESM contexts without a default export.

const generate = require('generate-file-webpack-plugin');

The named export 'GenerateFilePlugin' was added in v1.0.0 as the class name. The default export is the factory function. Both are functionally equivalent.

const { GenerateFilePlugin } = require('generate-file-webpack-plugin');

Same as GenerateFilePlugin, but using the full name. Prefer the shorter GenerateFilePlugin.

const { GenerateFileWebpackPlugin } = require('generate-file-webpack-plugin');

Demonstrates generating two files: a JSON file with version info and a text file with build timestamp using a function.

const generate = require('generate-file-webpack-plugin'); module.exports = { entry: './src/index.js', output: { path: __dirname + '/dist', filename: 'bundle.js' }, plugins: [ generate({ file: 'version.json', content: JSON.stringify({ version: '1.0.0', buildTime: Date.now() }) }), generate({ file: 'about.txt', content: () => `Built at ${new Date().toISOString()}` }) ] };
Debug
Known footguns
gotchaDo not use `new generate()` – it is a factory function, not a constructor. Using `new` will cause the plugin to be applied twice.
deprecatedThe named export `GenerateFileWebpackPlugin` is deprecated and will be removed in a future version. Use `GenerateFilePlugin` instead.
gotchaRelative file paths are resolved relative to webpack's `output.path`, not the project root.
gotchaThe `content` option as a function receives no arguments; attempting to access `compilation` or other webpack internals will fail.
gotchaWhen using `debug: true`, the plugin logs to console via `console.log()`, which may interfere with CI log outputs.
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