Files
open-wc/packages/building-utils/index-html/utils.js
2020-04-20 19:01:46 +02:00

28 lines
558 B
JavaScript

const crypto = require('crypto');
function createContentHash(content) {
return crypto.createHash('md4').update(content).digest('hex');
}
function cleanImportPath(path) {
if (path.startsWith('/')) {
return path;
}
if (path.startsWith('../') || path.startsWith('./')) {
return path;
}
return `./${path}`;
}
function polyfillFilename(polyfill, polyfillsConfig) {
return `${polyfill.name}${polyfillsConfig.hashPolyfills ? `.${polyfill.hash}` : ''}`;
}
module.exports = {
createContentHash,
cleanImportPath,
polyfillFilename,
};