@trendyminds/rollup-plugin-hashed-mapping
v0.1.2
Published
A rollup plugin that generates a hash manifest for your compiled assets
Downloads
4
Readme
Rollup Plugin Hashed Mapping
A [rollup] plugin that generates a manifest.hash.json
file for your compiled assets. This is a fork of the wonderful plugin provided by surma.
$ npm i @trendyminds/rollup-plugin-hashed-mapping -D
Usage
NOTE: Your file name format must use the [name].[hash].js
syntax. Additionally, only .css
and .js
assets will be added into the JSON manifest file.
// rollup.config.js
import hashedMapping from "@trendyminds/rollup-plugin-hashed-mapping";
export default {
input: "src/main.js",
output: {
dir: "dist",
format: "amd",
entryFileNames: "[name].[hash].js"
},
plugins: [hashedMapping()]
};
Using the hashed filenames in your templates
This plugin does not rename assets in your templating files. This merely provides a JSON mapping of the old and the new names. You should then use this file as a lookup table. Here's an example of how this might work if you are using a server-side templating language such as Twig:
<link rel="stylesheet" href="/path/to/your/assets/{{ asset('app.css') }}">
<script src="/path/to/your/assets/{{ asset('app.js') }}"></script>
And your {{ asset('') }}
function looks up the filename in the JSON manifest and fetches the hashed version.
Options
{
// ...
plugins: [
hashedMapping({
file: "manifest.hash.json"
})
];
}