Registry / devops / emit-file-webpack-plugin

emit-file-webpack-plugin

JSON →
library2.0.1jsnpmunverified

Webpack plugin to emit arbitrary files into the compilation output. Current stable version is 2.0.1, released in 2023. Low release cadence. Differentiator: handles async content, hash injection, and custom output paths without extra dependencies like copy-webpack-plugin. Ships TypeScript declarations. Requires webpack and webpack-sources as peer dependencies.

npm install emit-file-webpack-plugin
INSTALL
IMPORT
SIG · EMIT-FILE-WEBPACK-
E
emit-file-webpack-plugin
devopsjavascriptv2.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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.

EmitFilePlugin
import EmitFilePlugin from 'emit-file-webpack-plugin'
const EmitFilePlugin = require('emit-file-webpack-plugin').default
Default export; in CommonJS you can use require() directly without .default.
EmitFilePlugin
const { EmitFilePlugin } = require('emit-file-webpack-plugin')
const EmitFilePlugin = require('emit-file-webpack-plugin').EmitFilePlugin
Named export is not available in CJS; only default export exists.
EmitFilePlugin
import EmitFilePlugin from 'emit-file-webpack-plugin'
import { EmitFilePlugin } from 'emit-file-webpack-plugin'
Named import is incorrect; the package provides a default export only.

Shows basic usage using CommonJS require with a JSON output file.

const EmitFilePlugin = require('emit-file-webpack-plugin'); module.exports = { // ... other webpack config plugins: [ new EmitFilePlugin({ filename: 'version.json', content: JSON.stringify({ version: process.env.npm_package_version || '0.0.0' }) }) ] };
Debug
Known issues
breakingIn v2.0.0, the plugin now respects overridden .toString() on content objects. Previously, non-string/non-buffer content would always be JSON.stringify'd. If your content object overrides toString but you relied on JSON.stringify behavior, this change may break your output.
fix
If you need JSON.stringify, use JSON.stringify(content) explicitly in the content option.
affects: >=2.0.0 <3.0.0
gotchaThe 'path' option can be relative to webpack's output path or absolute. If you specify a relative path, it's resolved from webpack's output.path, not from the project root.
fix
Always use absolute paths with path.resolve() to avoid confusion.
affects: >=0.0.0
deprecatedWebpack 5 removed the require('webpack-sources'); you must install webpack-sources as a separate peer dependency. The plugin does not bundle it.
fix
Install webpack-sources: npm install --save-dev webpack-sources
affects: >=2.0.0
gotchaIf you use the 'hash' option, and you don't include '[hash]' in the filename, the hash will be appended as a query string (e.g., index.js?hash). This may not work for all asset types (e.g., images in CSS).
fix
Explicitly add '[hash]' in the filename to control placement, e.g., 'index.[hash].js'.
affects: >=1.1.0
Errors
Common errors & fixes
TypeError: Class extends value undefined is not a constructor or null
Missing or incompatible webpack and webpack-sources peer dependencies.
fix
Install peer dependencies: npm install --save-dev webpack webpack-sources
Error: Couldn't find plugin with the id "EmitFilePlugin"
Incorrect import of the plugin (named import instead of default).
fix
Use default import: import EmitFilePlugin from 'emit-file-webpack-plugin' or const EmitFilePlugin = require('emit-file-webpack-plugin').
TypeError: compilation.hooks.processAssets is not a function
Using the plugin with webpack 4 or older, where processAssets hook does not exist.
fix
Upgrade to webpack 5 or use an older version of the plugin that supports webpack 4.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
webpackrequiredPeer dependency; the plugin interfaces with webpack's compilation hooks.
webpack-sourcesrequiredPeer dependency; used for creating source map–aware assets.
Agent activity
2 hits · last 30 days
node
2
Resources
emit-file-webpack-plugin — npm install emit-file-webpack-plugin · libregistry