webpack plugin for generating asset manifests
Installations
npm install webpack-manifest-plugin
Developer
shellscape
Developer Guide
Module System
CommonJS
Min. Node Version
>=12.22.0
Typescript Support
No
Node Version
14.19.0
NPM Version
6.14.16
Statistics
1,437 Stars
209 Commits
184 Forks
17 Watching
6 Branches
53 Contributors
Updated on 26 Nov 2024
Bundle Size
79.95 kB
Minified
20.72 kB
Minified + Gzipped
Languages
JavaScript (75.94%)
TypeScript (23.93%)
Shell (0.13%)
Total Downloads
Cumulative downloads
Total Downloads
1,043,311,229
Last day
-2.8%
729,234
Compared to previous day
Last week
3.9%
3,855,243
Compared to previous week
Last month
6.7%
16,049,199
Compared to previous month
Last year
-11.7%
195,404,173
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Peer Dependencies
1
Dev Dependencies
28
webpack-manifest-plugin
A Webpack plugin for generating an asset manifest.
:heart: Please consider Sponsoring my work
Requirements
webpack-manifest-plugin
is an evergreen 🌲 module.
This module requires an Active LTS Node version (v12.0.0+) and Webpack v5.0.0.
Contributing
This repository leverages pnpm for dependency management.
To begin, please install pnpm
:
1$ npm install pnpm -g
Install
Using npm:
1npm install webpack-nano webpack-manifest-plugin --save-dev
Note: We recommend using webpack-nano, a very tiny, very clean webpack CLI.
Usage
Create a webpack.config.js
file:
1const { WebpackManifestPlugin } = require('webpack-manifest-plugin'); 2const options = { ... }; 3 4module.exports = { 5 // an example entry definition 6 entry: [ 'app.js' ], 7 ... 8 plugins: [ 9 new WebpackManifestPlugin(options) 10 ] 11};
And run webpack
:
1$ npx wp
With the default options, the example above will create a manifest.json
file in the output directory for the build. The manifest file will contain a map of source filenames to the corresponding build output file. e.g.
1{ 2 "dist/batman.js": "dist/batman.1234567890.js", 3 "dist/joker.js": "dist/joker.0987654321.js" 4}
Options
assetHookStage
Type: Number
Default: Infinity
If you need to consume the output of this plugin in another plugin, it can be useful to adjust the stage at which the manifest is generated. Pass a new stage to assetHookStage
to change when the manifest is generated. See the docs on processAssets
for more detail.
Note: any files added to the compilation after the stage specified will not be included in the manifest.
basePath
Type: String
Default: ''
Specifies a path prefix for all keys in the manifest. Useful for including your output path in the manifest.
fileName
Type: String
Default: manifest.json
Specifies the file name to use for the resulting manifest. By default the plugin will emit manifest.json
to your output directory. Passing an absolute path to the fileName
option will override both the file name and path.
filter
Type: Function
Default: undefined
Allows filtering the files which make up the manifest. The passed function should match the signature of (file: FileDescriptor) => Boolean
. Return true
to keep the file, false
to remove the file.
generate
Type: Function
Default: undefined
A custom Function
to create the manifest. The passed function should match the signature of (seed: Object, files: FileDescriptor[], entries: string[]) => Object
and can return anything as long as it's serialisable by JSON.stringify
.
map
Type: Function
Default: undefined
Allows modifying the files which make up the manifest. The passed function should match the signature of (file: FileDescriptor) => FileDescriptor
where an object matching FileDescriptor
is returned.
publicPath
Type: String
Default: <webpack-config>.output.publicPath
A path prefix that will be added to values of the manifest.
removeKeyHash
Type: RegExp | false
Default: /([a-f0-9]{32}\.?)/gi
If set to a valid RegExp
, removes hashes from manifest keys. e.g.
1{ 2 "index.c5a9bff71fdfed9b6046.html": "index.c5a9bff71fdfed9b6046.html" 3}
1{ 2 "index.html": "index.c5a9bff71fdfed9b6046.html" 3}
The default value for this option is a regular expression targeting Webpack's default md5 hash. To target other hashing functions / algorithms, set this option to an appropriate RegExp
. To disable replacing the hashes in key names, set this option to false
.
seed
Type: Object
Default: {}
A cache of key/value pairs used to seed the manifest. This may include a set of custom key/value pairs to include in your manifest, or may be used to combine manifests across compilations in multi-compiler mode. To combine manifests, pass a shared seed object to each compiler's WebpackManifestPlugin
instance.
serialize
Type: Function(Object) => string
Default: undefined
A Function
which can be leveraged to serialize the manifest in a different format than json. e.g. yaml
.
sort
Type: Function
Default: undefined
Allows sorting the files which make up the manifest. The passed function should match the signature of (fileA: FileDescriptor, fileB: FileDescriptor) => Number
. Return 0
to indicate no change, -1
to indicate the file should be moved to a lower index, and 1
to indicate the file shoud be moved to a higher index.
useEntryKeys
Type: Boolean
Default: false
If true
, the keys specified in the entry
property will be used as keys in the manifest. No file extension will be added (unless specified as part of an entry
property key).
useLegacyEmit
Type: Boolean
Default: false
If true
, the manifest will be written on the deprecated webpack emit
hook to be compatible with not yet updated webpack plugins.
A lot of webpack plugins are not yet updated to match the new webpack 5 API. This is a problem when other plugins use the deprecated emit
hook. The manifest will be written before these other plugins and thus files are missing on the manifest.
writeToFileEmit
Type: Boolean
Default: false
If true
, will emit the manifest to the build directory and in memory for compatibility with webpack-dev-server
.
Manifest File Descriptor
This plugin utilizes the following object structure to work with files. Many options for this plugin utilize the structure below.
1{ 2 chunk?: Chunk; 3 isAsset: boolean; 4 isChunk: boolean; 5 isInitial: boolean; 6 isModuleAsset: boolean; 7 name: string | null; 8 path: string; 9}
chunk
Type: Chunk
Only available if isChunk
is true
isInitial
Type: Boolean
Is required to run you app. Cannot be true
if isChunk
is false
.
isModuleAsset
Type: Boolean
Is required by a module. Cannot be true
if isAsset
is false
.
Compiler Hooks
This plugin supports the following hooks via the getCompilerHooks
export; afterEmit
, beforeEmit
. These hooks can be useful, e.g. changing manifest contents before emitting to disk.
getCompilerHooks
Returns: { afterEmit: SyncWaterfallHook, beforeEmit: SyncWaterfallHook }
Usage
1const { getCompilerHooks } = require('webpack-manifest-plugin'); 2 3class BatmanPlugin { 4 apply(compiler) { 5 const { beforeEmit } = getCompilerHooks(compiler); 6 7 beforeEmit.tap('BatmanPlugin', (manifest) => { 8 return { ...manifest, name: 'hello' }; 9 }); 10 } 11}
Notes
- If using this plugin with
webpack-clean
andwebpack-dev-server
, please review this issue.
Attiribution
Special thanks to Dane Thurber, the original author of this plugin, without whom this plugin would not exist.
Meta
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 11/30 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/node-windows.yml:1
- Warn: no topLevel permission defined: .github/workflows/pr-title.yml:1
- Warn: no topLevel permission defined: .github/workflows/validate.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node-windows.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/shellscape/webpack-manifest-plugin/node-windows.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node-windows.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/shellscape/webpack-manifest-plugin/node-windows.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pr-title.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/shellscape/webpack-manifest-plugin/pr-title.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/pr-title.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/shellscape/webpack-manifest-plugin/pr-title.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/shellscape/webpack-manifest-plugin/validate.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/validate.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/shellscape/webpack-manifest-plugin/validate.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/validate.yml:37
- Info: 0 out of 5 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 11 are checked with a SAST tool
Reason
11 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Score
2.8
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to webpack-manifest-plugin
@types/webpack-manifest-plugin
TypeScript definitions for webpack-manifest-plugin
webpack-import-map-plugin
A webpack plugin to help generate import maps for outputted entry files, based on webpack-manifest-plugin
webpack-assets-manifest
This Webpack plugin will generate a JSON file that matches the original filename with the hashed version.
rspack-manifest-plugin
A Rspack Plugin for generating Asset Manifests