@typed/content-hash
Version:
Content hash a directory of HTML/JS/CSS files and other static assets
22 lines • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateAssetManfiestFromRegistry = void 0;
const FxEnv_1 = require("@typed/fp/FxEnv");
const path_1 = require("path");
const logging_1 = require("../application/services/logging");
const applyOrigin_1 = require("./applyOrigin");
const getHashedPath_1 = require("./hashes/getHashedPath");
const generateAssetManfiestFromRegistry = (directory, registry, hashLength, baseUrl) => (0, FxEnv_1.Do)(function* (_) {
yield* _((0, logging_1.info)(`Generating Asset Manifest...`));
const manifest = {};
for (const document of registry.values()) {
const from = document.filePath;
const to = (0, getHashedPath_1.getHashedPath)(document, registry, hashLength);
manifest[path_1.posix.relative(directory, from)] = baseUrl
? (0, applyOrigin_1.applyOrigin)(directory, to, baseUrl)
: path_1.posix.relative(directory, to);
}
return manifest;
});
exports.generateAssetManfiestFromRegistry = generateAssetManfiestFromRegistry;
//# sourceMappingURL=generateAssetManifest.js.map