{"_id":"@blackrabbit99/webpack-assets-manifest","_rev":"1-5e6d4899d074090a3d7f0b82a5babdf5","name":"@blackrabbit99/webpack-assets-manifest","dist-tags":{"latest":"5.0.6"},"versions":{"5.0.6":{"name":"@blackrabbit99/webpack-assets-manifest","version":"5.0.6","description":"This Webpack plugin will generate a JSON file that matches the original filename with the hashed version.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/webdeveric/webpack-assets-manifest.git"},"bugs":{"url":"https://github.com/webdeveric/webpack-assets-manifest/issues"},"homepage":"https://github.com/webdeveric/webpack-assets-manifest","keywords":["webpack-assets-manifest","webpack-plugin","webpack","plugin","assets","manifest","json","subresource","integrity","sri"],"main":"src/WebpackAssetsManifest.js","scripts":{"lint":"eslint --fix src test","typecheck":"tsc","spellcheck":"cspell --no-progress './{.github,src,test}/**/*.{js,json}' './*.{md,js}' './package.json'","test":"nyc mocha --colors","test:report":"nyc --reporter=lcov --reporter=text mocha --colors","lcov":"nyc report --reporter=text-lcov > coverage.lcov","pre-commit":"lint-staged","prepare":"husky install","prepublishOnly":"npm run lint && npm test"},"lint-staged":{"*.{js,json,md}":"cspell lint --no-progress --no-summary --no-must-find-files","*.js":"eslint --fix"},"engines":{"node":">=10.13.0"},"author":{"name":"Eric King","email":"eric@webdeveric.com","url":"http://webdeveric.com/"},"dependencies":{"chalk":"^4.0","deepmerge":"^4.0","lockfile":"^1.0","lodash.get":"^4.0","lodash.has":"^4.0","schema-utils":"^3.0","tapable":"^2.0"},"peerDependencies":{"webpack":"^5.2.0"},"devDependencies":{"@types/lodash.get":"^4.4.6","@types/lodash.has":"^4.5.6","@types/node":"^16.7.13","@types/tapable":"^2.2.2","@types/webpack-sources":"^3.2.0","@webdeveric/eslint-config":"^0.2.1","chai":"^4.3.0","chai-spies":"^1.0.0","compression-webpack-plugin":"^7.1.2","copy-webpack-plugin":"^8.1.1","cspell":"^5.5.2","css-loader":"^5.2.4","eslint":"^7.26.0","file-loader":"^6.2.0","fs-extra":"^9.1.0","husky":"^6.0.0","lint-staged":"^10.5.4","memory-fs":"^0.5.0","mini-css-extract-plugin":"^1.6.0","mkdirp":"^1.0.4","mocha":"^8.4.0","nyc":"^15.1.0","rimraf":"^3.0.2","superagent":"^6.1.0","typescript":"^4.4.2","webpack":"^5.38.1","webpack-dev-server":"^3.11.2","webpack-subresource-integrity":"^1.5.2"},"gitHead":"3b1b6388b73dc82aa215bd2aa97b2e84758fa794","_id":"@blackrabbit99/webpack-assets-manifest@5.0.6","_nodeVersion":"16.13.2","_npmVersion":"8.1.2","dist":{"integrity":"sha512-rfI9ffiiWrOh71S7QtszRIOHbFXn1/M3nMtUEjkGKcxrAU1RShX9odxEV+eyJfeOtf+ONJJLsPUu79/KTstlfA==","shasum":"30ee1b29b9afc5f1c7c464c869cabba9a7c3a03e","tarball":"https://registry.npmjs.org/@blackrabbit99/webpack-assets-manifest/-/webpack-assets-manifest-5.0.6.tgz","fileCount":6,"unpackedSize":47436,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh5resCRA9TVsSAnZWagAAu9kP/3yCtnejDJoAXNJh7YBp\nkFekn+wjhJQbIDErXZKNF3kvTCc4O7PwFumMsgpspdWMmT7W9HZ1FtqdbUsk\nMCIFoi2kWgNY48Ew7zQEVPlaGrghjOkGjaRwT0n7opm4Uc/Tgt3U0nx3zVSn\nftT/XMA3EYSXB7hvPD+XX3dpJVxmBi1xq8URiEzZ2pl5pBHvXXdryyTO46yu\n17EqymE4fpqfcI+N0e+23ML0E+Pv4tcrxKFNme1OA+7SOIM8Q1MZjIvt7vno\nCrOECXjosF4JFdaHBxDlSuV+YpGX+DnaFJKiAqmG0UfeQTkhJK7CRAct64Xn\nIBrkov0Su0weJf0bIEbonSQ2Ifm5+WujsaZ1xKQDyrEvgAWRy8xt0U3yQOec\ngdJN75VtBut5/j+r8U31no8Pf1MLbiiwL6zay0AUdOpqPbNVsTfSP6jIBbol\nSTgPnXFUvvk6CRSoke3JZR5+V1+7iVQDRadp4qo04xfUNPPVNJ582C9WhH0l\n4ftwCk+tBPvNHPx2NyN1OlqfdQimI+C4WUepy6xqNIICAB037+wdcDcALrug\n8GBH0Hy+nlyMtgdPFlQu9PAocEMTZnffcV1q82XvF3zzelkNZVpcmaDSnCqK\nPyTNhKHrbKG9Eo9ZN+rvYKNdwNjZDDop78F28fUrf7767L1cj39TFk9aghD8\nJb7l\r\n=KDzb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDL0Rd7XFJSbW/Ve5vjSQCPC/aN0lYdaeWOqI90jFFPiAiEAnedzQN9wdQPRsArmgapnMjIuHIZ9thb2TShBEVhoCRg="}]},"_npmUser":{"name":"blackrabbit99","email":"myzlio@gmail.com"},"directories":{},"maintainers":[{"name":"blackrabbit99","email":"myzlio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webpack-assets-manifest_5.0.6_1642510251889_0.629676102581092"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-18T12:50:51.828Z","5.0.6":"2022-01-18T12:50:52.005Z","modified":"2022-04-04T19:22:22.228Z"},"maintainers":[{"name":"blackrabbit99","email":"myzlio@gmail.com"}],"description":"This Webpack plugin will generate a JSON file that matches the original filename with the hashed version.","homepage":"https://github.com/webdeveric/webpack-assets-manifest","keywords":["webpack-assets-manifest","webpack-plugin","webpack","plugin","assets","manifest","json","subresource","integrity","sri"],"repository":{"type":"git","url":"git+https://github.com/webdeveric/webpack-assets-manifest.git"},"author":{"name":"Eric King","email":"eric@webdeveric.com","url":"http://webdeveric.com/"},"bugs":{"url":"https://github.com/webdeveric/webpack-assets-manifest/issues"},"license":"MIT","readme":"# Webpack Assets Manifest\n\n[![Build Status](https://github.com/webdeveric/webpack-assets-manifest/workflows/Node.js%20CI/badge.svg)](https://github.com/webdeveric/webpack-assets-manifest/actions)\n[![codecov](https://codecov.io/gh/webdeveric/webpack-assets-manifest/branch/master/graph/badge.svg)](https://codecov.io/gh/webdeveric/webpack-assets-manifest)\n[![dependencies Status](https://david-dm.org/webdeveric/webpack-assets-manifest/status.svg)](https://david-dm.org/webdeveric/webpack-assets-manifest)\n[![devDependencies Status](https://david-dm.org/webdeveric/webpack-assets-manifest/dev-status.svg)](https://david-dm.org/webdeveric/webpack-assets-manifest?type=dev)\n\nThis webpack plugin will generate a JSON file that matches the original filename with the hashed version.\n\n## Installation\n\n```shell\nnpm install webpack-assets-manifest --save-dev\n```\n\n## New in version 5\n\n* Compatible with webpack 5 only (5.1+ required).\n* Supports finding [asset modules](https://webpack.js.org/guides/asset-modules/).\n* Updated options schema to prevent additional properties. This helps with catching typos in option names.\n* :warning: Updated default value of the `output` option to be `assets-manifest.json`.\n  This is to prevent confusion when working with [Web app manifests](https://developer.mozilla.org/en-US/docs/Web/Manifest) or [WebExtension manifests](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json).\n  \n## New in version 4\n\n* Requires Node 10+.\n* Compatible with webpack 4 only (4.40+ required).\n* Added options: [`enabled`](#enabled), [`entrypointsUseAssets`](#entrypointsUseAssets), [`contextRelativeKeys`](#contextRelativeKeys).\n* Updated [`writeToDisk`](#writeToDisk) option to default to `auto`.\n* Use lock files for various operations.\n* `done` hook is now an `AsyncSeriesHook`.\n* :warning: The structure of the `entrypoints` data has been updated to include `preload` and `prefetch` assets. Assets for an entrypoint are now included in an `assets` property under the entrypoint.\n\n  Example:\n\n  ```json\n  {\n    \"entrypoints\": {\n      \"main\": {\n        \"assets\": {\n          \"css\": [\n            \"main.css\"\n          ],\n          \"js\": [\n            \"main.js\"\n          ]\n        },\n        \"prefetch\": {\n          \"js\": [\n            \"prefetch.js\"\n          ]\n        },\n        \"preload\": {\n          \"js\": [\n            \"preload.js\"\n          ]\n        }\n      }\n    }\n  }\n  ```\n\n## Usage\n\nIn your webpack config, require the plugin then add an instance to the `plugins` array.\n\n```js\nconst path = require('path');\nconst WebpackAssetsManifest = require('webpack-assets-manifest');\n\nmodule.exports = {\n  entry: {\n    // Your entry points\n  },\n  output: {\n    path: path.join( __dirname, 'dist' ),\n    filename: '[name]-[hash].js',\n    chunkFilename: '[id]-[chunkhash].js',\n  },\n  module: {\n    // Your loader rules go here.\n  },\n  plugins: [\n    new WebpackAssetsManifest({\n      // Options go here\n    }),\n ],\n};\n```\n\n## Sample output\n\n```json\n{\n  \"main.js\": \"main-9c68d5e8de1b810a80e4.js\",\n  \"main.css\": \"main-9c68d5e8de1b810a80e4.css\",\n  \"images/logo.svg\": \"images/logo-b111da4f34cefce092b965ebc1078ee3.svg\"\n}\n```\n\n---\n\n## Options ([read the schema](src/options-schema.json))\n\n### `enabled`\n\nType: `boolean`\n\nDefault: `true`\n\nIs the plugin enabled?\n\n### `output`\n\nType: `string`\n\nDefault: `assets-manifest.json`\n\nThis is where to save the manifest file relative to your webpack `output.path`.\n\n### `assets`\n\nType: `object`\n\nDefault: `{}`\n\nData is stored in this object.\n\n#### Sharing data\n\nYou can share data between instances by passing in your own object in the `assets` option.\n\nThis is useful in [multi-compiler mode](https://github.com/webpack/webpack/tree/master/examples/multi-compiler).\n\n```js\nconst data = Object.create(null);\n\nconst manifest1 = new WebpackAssetsManifest({\n  assets: data,\n});\n\nconst manifest2 = new WebpackAssetsManifest({\n  assets: data,\n});\n```\n\n### `contextRelativeKeys`\n\nType: `boolean`\n\nDefault: `false`\n\nKeys are relative to the compiler context.\n\n### `space`\n\nType: `int`\n\nDefault: `2`\n\nNumber of spaces to use for pretty printing.\n\n### `replacer`\n\nType: `null`, `function`, or `array`\n\nDefault: `null`\n\n[Replacer reference](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)\n\nYou'll probably want to use the `transform` hook instead.\n\n### `fileExtRegex`\n\nType: `regex`\n\nDefault: `/\\.\\w{2,4}\\.(?:map|gz)$|\\.\\w+$/i`\n\nThis is the regular expression used to find file extensions. You'll probably never need to change this.\n\n### `writeToDisk`\n\nType: `boolean`, `string`\n\nDefault: `'auto'`\n\nWrite the manifest to disk using `fs`.\n\n:warning: If you're using another language for your site and you're using `webpack-dev-server` to process your assets during development,\nyou should set `writeToDisk: true` and provide an absolute path in `output` so the manifest file is actually written to disk and not kept only in memory.\n\n### `sortManifest`\n\nType: `boolean`, `function`\n\nDefault: `true`\n\nThe manifest is sorted alphabetically by default. You can turn off sorting by setting `sortManifest: false`.\n\nIf you want more control over how the manifest is sorted, you can provide your own\n[comparison function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters).\nSee the [sorted](examples/sorted.js) example.\n\n```js\nnew WebpackAssetsManifest({\n  sortManifest(a, b) {\n    // Return -1, 0, or 1\n  }\n});\n```\n\n### `merge`\n\nType: `boolean`, `string`\n\nDefault: `false`\n\nIf the `output` file already exists and you'd like to add to it, use `merge: true`.\nThe default behavior is to use the existing keys/values without modification.\n\n```js\nnew WebpackAssetsManifest({\n  output: '/path/to/manifest.json',\n  merge: true\n});\n```\n\nIf you need to customize during merge, use `merge: 'customize'`. \n\nIf you want to know if `customize` was called when merging with an existing manifest, you can check `manifest.isMerging`.\n\n```js\nnew WebpackAssetsManifest({\n  merge: 'customize',\n  customize(entry, original, manifest, asset) {\n    if ( manifest.isMerging ) {\n      // Do something\n    }\n  },\n}),\n```\n\n### `publicPath`\n\nType: `string`, `function`, `boolean`,\n\nDefault: `null`\n\nWhen using `publicPath: true`, your webpack config `output.publicPath` will be used as the value prefix.\n\n```js\nconst manifest = new WebpackAssetsManifest({\n  publicPath: true,\n});\n```\n\nWhen using a string, it will be the value prefix. One common use is to prefix your CDN URL.\n\n```js\nconst manifest = new WebpackAssetsManifest({\n  publicPath: '//cdn.example.com',\n});\n```\n\nIf you'd like to have more control, use a function. See the [custom CDN](examples/custom-cdn.js) example.\n\n```js\nconst manifest = new WebpackAssetsManifest({\n  publicPath(filename, manifest)\n  {\n    // customize filename here\n    return filename;\n  }\n});\n```\n\n### `entrypoints`\n\nType: `boolean`\n\nDefault: `false`\n\nInclude `compilation.entrypoints` in the manifest file.\n\n### `entrypointsKey`\n\nType: `string`, `boolean`\n\nDefault: `entrypoints`\n\nIf this is set to `false`, the `entrypoints` will be added to the root of the manifest.\n\n### `entrypointsUseAssets`\n\nType: `boolean`\n\nDefault: `false`\n\nEntrypoint data should use the value from `assets`, which means the values could be customized and not just a `string` file path.\nThis new option defaults to `false` so the new behavior is opt-in.\n\n### `integrity`\n\nType: `boolean`\n\nDefault: `false`\n\nInclude the [subresource integrity hash](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).\n\n### `integrityHashes`\n\nType: `array`\n\nDefault: `[ 'sha256', 'sha384', 'sha512' ]`\n\nHash algorithms to use when generating SRI. For browsers, the currently the allowed integrity hashes are `sha256`, `sha384`, and `sha512`.\n\nOther hash algorithms can be used if your target environment is not a browser.\nIf you were to create a tool to audit your S3 buckets for\n[data integrity](https://aws.amazon.com/premiumsupport/knowledge-center/data-integrity-s3/),\nyou could use something like this [example](examples/aws-s3-data-integrity.js) to record the `md5` hashes.\n\n### `integrityPropertyName`\n\nType: `string`\n\nDefault: `integrity`\n\nThis is the property that will be set on each entry in `compilation.assets`, which will then be available during `customize`.\nIt is customizable so that you can have multiple instances of this plugin and not have them overwrite the `currentAsset.integrity` property.\n\nYou'll probably only need to change this if you're using multiple instances of this plugin to create different manifests.\n\n### `apply`\n\nType: `function`\n\nDefault: `null`\n\nCallback to run after setup is complete.\n\n### `customize`\n\nType: `function`\n\nDefault: `null`\n\nCallback to customize each entry in the manifest.\n\nYou can use this to customize entry names for example. In the sample below, we adjust `img` keys so that it's easier to use them with a template engine:\n\n```javascript\nnew WebpackAssetsManifest({\n  customize(entry) {\n    if (entry.key.startsWith('img/')) {\n      return { key: entry.key.split('img/')[1], value: entry.value };\n    }\n\n    return o;\n  }\n}\n```\n\nThe function is called per each entry and provides you a way to intercept and rewrite each object. The result is then merged into a whole manifest.\n\n[View the example](examples/customized.js) to see what else you can do with this function.\n\n### `transform`\n\nType: `function`\n\nDefault: `null`\n\nCallback to transform the entire manifest.\n\n### `done`\n\nType: `function`\n\nDefault: `null`\n\nCallback to run after the compilation is done and the manifest has been written.\n\n---\n\n### Hooks\n\nThis plugin is using hooks from [Tapable](https://github.com/webpack/tapable/).\n\nThe `apply`, `customize`, `transform`, and `done` options are automatically tapped into the appropriate hook.\n\n| Name | Type | Callback signature |\n| ---- | ---- | --------- |\n| `apply` | `SyncHook` | `function(manifest){}` |\n| `customize` | `SyncWaterfallHook` | `function(entry, original, manifest, asset){}` |\n| `transform` | `SyncWaterfallHook` | `function(assets, manifest){}` |\n| `done` | `AsyncSeriesHook` | `async function(manifest, stats){}` |\n| `options` | `SyncWaterfallHook` | `function(options){}` |\n| `afterOptions` | `SyncHook` | `function(options){}` |\n\n#### Tapping into hooks\n\nTap into a hook by calling the `tap` method on the hook as shown below.\n\nIf you want more control over exactly what gets added to your manifest, then use the `customize` and `transform` hooks.\nSee the [customized](examples/customized.js) and [transformed](examples/transformed.js) examples.\n\n```js\nconst manifest = new WebpackAssetsManifest();\n\nmanifest.hooks.apply.tap('YourPluginName', function(manifest) {\n  // Do something here\n  manifest.set('some-key', 'some-value');\n});\n\nmanifest.hooks.customize.tap('YourPluginName', function(entry, original, manifest, asset) {\n  // customize entry here\n  return entry;\n});\n\nmanifest.hooks.transform.tap('YourPluginName', function(assets, manifest) {\n  // customize assets here\n  return assets;\n});\n\nmanifest.hooks.options.tap('YourPluginName', function(options) {\n  // customize options here\n  return options;\n});\n\nmanifest.hooks.done.tap('YourPluginName', function(manifest, stats) {\n  console.log(`The manifest has been written to ${manifest.getOutputPath()}`);\n  console.log(`${manifest}`);\n});\n\nmanifest.hooks.done.tapPromise('YourPluginName', async (manifest, stats) => {\n  await yourAsyncOperation();\n});\n```\n\nThese hooks can also be set by passing them in the constructor options.\n\n```js\nnew WebpackAssetsManifest({\n  done(manifest, stats) {\n    console.log(`The manifest has been written to ${manifest.getOutputPath()}`);\n    console.log(`${manifest}`);\n  }\n});\n```\n\n## Manifest methods\n\nIf the manifest instance is passed to a hook, you can use the following methods to manage what goes into the manifest.\n\n- `has(key)`\n- `get(key)`\n- `set(key, value)`\n- `setRaw(key, value)`\n- `delete(key)`\n\nIf you want to write the manifest to another location, you can use `writeTo(destination)`.\n\n```js\nnew WebpackAssetsManifest({\n  async done(manifest) {\n    await manifest.writeTo('/some/other/path/assets-manifest.json');\n  }\n});\n```\n","readmeFilename":"readme.md"}