
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
manifest-rev
Advanced tools
Dynamically load assets into your views, emails, etc. from your `rev-manifest.json` manifest revision file
Dynamically load assets into your views, emails, etc. from your
rev-manifest.json
manifest revision file (e.g.<script src="{{ manifest('foo.js'); }}"></script>
would return<script src="/foo-0775041dd4.js"></script>
when rendered).
npm:
npm install manifest-rev
yarn:
yarn add manifest-rev
const path = require('path');
const Koa = require('koa');
const manifestRev = require('manifest-rev');
const app = new Koa();
app.use((ctx, next) => {
ctx.state.manifest = manifestRev({
manifest: path.join(__dirname, 'build', 'rev-manifest.json'),
prepend: '/'
});
return next();
});
// ...
Call the manifest(str, ?prop)
helper function in your views when you need to include assets (requires a templating engine).
pug:
html
head
title Foo
body
h1 Foo
script(src=manifest('foo.js', 'path'))
<html>
<head>
<title>Foo</title>
</head>
<body>
<h1>Foo</h1>
<script src="<%= manifest('foo.js', 'path'); %>" integrity="<%= manifest('foo.js', 'integrity') %>"></script>
</body>
</html>
nunjucks (via koa-nunjucks-promise):
<html>
<head>
<title>Foo</title>
</head>
<body>
<h1>Foo</h1>
<script src="{{ manifest('foo.js'); }}" integrity="{{ manifest('foo.js', 'integrity'); }}"></script>
</body>
</html>
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.
manifest
(required) - path to a valid rev-manifest.json
file (e.g. as built by gulp-rev or gulp-rev-all)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 <script src="/dist/foo-0775041dd4.js"></script>
(defaults to /
)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.
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.Name | Website |
---|---|
Nick Baugh | http://niftylettuce.com/ |
FAQs
Dynamically load assets into your views, emails, etc. from your `rev-manifest.json` manifest revision file
The npm package manifest-rev receives a total of 99 weekly downloads. As such, manifest-rev popularity was classified as not popular.
We found that manifest-rev demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.