webpack-fingerprint
webpack-fingerprint copied to clipboard
Generate list of all libraries imported in bundling process and their versions.
Webpack Fingerprint Plugin
This plugin will generate list of node modules (along with their version and licence) which were imported into the bundle and place it in an JSON file
The most common usage will be for tracking what versions are deployed with current version of your application and tracking their licenses for legal requirements.
Installation
The plugin is available via npm:
$ npm install --save webpack-fingerprint
Examples
Basic
var WebpackFingerprint = require("webpack-fingerprint");
module.exports = {
plugins: [
new WebpackFingerprint({
filename: "fingerprint.json" // Default
})
]
}
Will produce a file called fingerprint.json with following info:
{
"date": "2017-09-17T15:56:50.468Z",
"version": "1.0.0",
"packages": {
"babel-loader": {
"version": "7.1.2",
"license": "MIT"
}
"react": {
"version": "15.6.1",
"license": "BSD-3-Clause"
}
"react-dom": {
"version": "15.6.1",
"license": "BSD-3-Clause"
}
}
}
Custom information
You can provide additional information to also be stored in the resulting file. To do so, pass a additional field on the configuration object.
var WebpackFingerprint = require("webpack-fingerprint");
module.exports = {
plugins: [
new WebpackFingerprint({
additional: {
build_number: process.env.CI_BUILD_NUMBER
}
})
]
}
Custom package details
You can also provide a transformer that will allow you to change the default information stored for each package. To do so, provide a transformer function, which will be called with each module package.json file and its return value will be used. If null is returned by all transformers, the package field will be omitted.
var WebpackFingerprint = require("webpack-fingerprint");
module.exports = {
plugins: [
new WebpackFingerprint({
transformer: (package) => ({
version: package.version,
author: package.author
})
})
]
}