{"id":18926767,"url":"https://github.com/ladjs/manifest-rev","last_synced_at":"2025-04-15T13:33:16.960Z","repository":{"id":57291123,"uuid":"208888383","full_name":"ladjs/manifest-rev","owner":"ladjs","description":"Dynamically load assets into your views, emails, etc. from your `rev-manifest.json` manifest revision file.","archived":false,"fork":false,"pushed_at":"2020-05-23T03:01:13.000Z","size":245,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T02:01:54.116Z","etag":null,"topics":["asset","buster","cache","dynamic","gulp","hash","json","load","loader","manifest","rev","rev-manifest","webpack"],"latest_commit_sha":null,"homepage":"https://lad.js.org","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ladjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-16T20:08:11.000Z","updated_at":"2024-11-08T11:50:56.000Z","dependencies_parsed_at":"2022-09-01T15:21:15.284Z","dependency_job_id":null,"html_url":"https://github.com/ladjs/manifest-rev","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fmanifest-rev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fmanifest-rev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fmanifest-rev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fmanifest-rev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ladjs","download_url":"https://codeload.github.com/ladjs/manifest-rev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249080473,"owners_count":21209533,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asset","buster","cache","dynamic","gulp","hash","json","load","loader","manifest","rev","rev-manifest","webpack"],"created_at":"2024-11-08T11:17:06.786Z","updated_at":"2025-04-15T13:33:16.663Z","avatar_url":"https://github.com/ladjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# manifest-rev\n\n[![build status](https://img.shields.io/travis/ladjs/manifest-rev.svg)](https://travis-ci.org/ladjs/manifest-rev)\n[![code coverage](https://img.shields.io/codecov/c/github/ladjs/manifest-rev.svg)](https://codecov.io/gh/ladjs/manifest-rev)\n[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)\n[![license](https://img.shields.io/github/license/ladjs/manifest-rev.svg)](\u003c\u003e)\n\n\u003e Dynamically load assets into your views, emails, etc. from your `rev-manifest.json` manifest revision file (e.g. `\u003cscript src=\"{{ manifest('foo.js'); }}\"\u003e\u003c/script\u003e` would return `\u003cscript src=\"/foo-0775041dd4.js\"\u003e\u003c/script\u003e` when rendered).\n\n\n## Table of Contents\n\n* [Install](#install)\n* [Usage](#usage)\n* [API](#api)\n* [Breaking changes in 2.0](#breaking-changes-in-20)\n* [Contributors](#contributors)\n* [License](#license)\n\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install manifest-rev\n```\n\n[yarn][]:\n\n```sh\nyarn add manifest-rev\n```\n\n\n## Usage\n\n```js\nconst path = require('path');\n\nconst Koa = require('koa');\nconst manifestRev = require('manifest-rev');\n\nconst app = new Koa();\n\napp.use((ctx, next) =\u003e {\n  ctx.state.manifest = manifestRev({\n    manifest: path.join(__dirname, 'build', 'rev-manifest.json'),\n    prepend: '/'\n  });\n  return next();\n});\n\n// ...\n```\n\n2. Call the `manifest(str, ?prop)` helper function in your views when you need to include assets (requires a templating engine).\n\n   \u003e [pug][]:\n\n   ```pug\n   html\n     head\n       title Foo\n     body\n       h1 Foo\n       script(src=manifest('foo.js', 'path'))\n   ```\n\n   \u003e [ejs][]\n\n   ```ejs\n   \u003chtml\u003e\n     \u003chead\u003e\n       \u003ctitle\u003eFoo\u003c/title\u003e\n     \u003c/head\u003e\n     \u003cbody\u003e\n       \u003ch1\u003eFoo\u003c/h1\u003e\n       \u003cscript src=\"\u003c%= manifest('foo.js', 'path'); %\u003e\" integrity=\"\u003c%= manifest('foo.js', 'integrity') %\u003e\"\u003e\u003c/script\u003e\n     \u003c/body\u003e\n   \u003c/html\u003e\n   ```\n\n   \u003e [nunjucks][] (via [koa-nunjucks-promise][]):\n\n   ```html\n   \u003chtml\u003e\n     \u003chead\u003e\n       \u003ctitle\u003eFoo\u003c/title\u003e\n     \u003c/head\u003e\n     \u003cbody\u003e\n       \u003ch1\u003eFoo\u003c/h1\u003e\n       \u003cscript src=\"{{ manifest('foo.js'); }}\" integrity=\"{{ manifest('foo.js', 'integrity'); }}\"\u003e\u003c/script\u003e\n     \u003c/body\u003e\n   \u003c/html\u003e\n   ```\n\n\n## API\n\n* `manifestRev(options)` - accepts a required `options` argument for setup. Returns middleware for use in `app.use` statement (which in turn binds to `ctx.state` a helper function called `manifest`). Here are the properties accepts in the `options` argument.\n\n  * `manifest` (**required**) - path to a valid `rev-manifest.json` file (e.g. as built by [gulp-rev][] or [gulp-rev-all][])\n  * `prepend` (optional) - string to prepend before file paths rendered after lookup (e.g. if you type `{{ manifest('foo.js'); }}` in your view, and you have passed `prepend: '/dist/'` in your setup, then your tag would render as `\u003cscript src=\"/dist/foo-0775041dd4.js\"\u003e\u003c/script\u003e` (defaults to `/`)\n\n* `manifest(str)` - the helper function returned when `manifestRev` is invoked in your app. Returns the string found from a lookup in your `rev-manifest.json` file for the `str` argument passed (e.g. if you type `{{ manifest('foo.js'); }}` in your view, then it returns for the value of the `foo.js` property as defined in your `manifest` file, such as `foo-0775041dd4.js`). If the found is not found, then the input `str` argument is returned.\n\n\n## Breaking changes in 2.0\n\n* `manifest(str)` is now `manifest(str, prop)` which now accepts a following property within your `rev-manifest.json` file. `prop` is optional and defaults to the path of the rev'd file. For example if you type `{{ manifest('foo.js', 'integrity'); }}` in your view, then it returns for the value of the `foo.js` file `integrity` property as defined in your `manifest` file, such as `sha256-YEWYfCFP9yc5DAF8K5AtLEyFuKZ1MNw+xQPm8g70LYY=`). If the found is not found, then the input `str` argument is returned.\n\n\n## Contributors\n\n| Name           | Website                    |\n| -------------- | -------------------------- |\n| **Nick Baugh** | \u003chttp://niftylettuce.com/\u003e |\n\n\n## License\n\n[MIT](LICENSE) © [Nick Baugh](http://niftylettuce.com/)\n\n\n## \n\n[npm]: https://www.npmjs.com/\n\n[yarn]: https://yarnpkg.com/\n\n[koa-nunjucks-promise]: https://github.com/hanai/koa-nunjucks-promise\n\n[gulp-rev-all]: https://github.com/smysnk/gulp-rev-all\n\n[gulp-rev]: https://github.com/sindresorhus/gulp-rev\n\n[nunjucks]: https://mozilla.github.io/nunjucks/\n\n[pug]: https://github.com/pugjs/pug\n\n[ejs]: http://ejs.co/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladjs%2Fmanifest-rev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fladjs%2Fmanifest-rev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladjs%2Fmanifest-rev/lists"}