Static asset revisioning by appending content hash to filenames
unicorn.css (.js or .jpg or images format)→unicorn-098f6bcd.cssand relace the reference which in the html code
$ npm i
jade模板编译:
gulp 或 gulp revJade
html编译:
gulp revHTML
- jade
- html
- js
- css
- images
/**
* @param string $filename
* @return string
*/
function asset_path($filename) {
$manifest_path = 'assets/rev-manifest.json';
if (file_exists($manifest_path)) {
$manifest = json_decode(file_get_contents($manifest_path), TRUE);
} else {
$manifest = [];
}
if (array_key_exists($filename, $manifest)) {
return $manifest[$filename];
}
return $filename;
}