зеркало из https://github.com/github/docs.git
24 строки
607 B
JavaScript
24 строки
607 B
JavaScript
const fs = require('fs')
|
|
const path = require('path')
|
|
const crypto = require('crypto')
|
|
|
|
// Get an MD4 Digest Hex content hash, loosely based on Webpack `[contenthash]`
|
|
function getContentHash (absFilePath) {
|
|
const buffer = fs.readFileSync(absFilePath)
|
|
const hash = crypto.createHash('md4')
|
|
hash.update(buffer)
|
|
return hash.digest('hex')
|
|
}
|
|
|
|
function getUrl (relFilePath) {
|
|
const absFilePath = path.join(process.cwd(), relFilePath)
|
|
return `/${relFilePath}?hash=${getContentHash(absFilePath)}`
|
|
}
|
|
|
|
module.exports = {
|
|
main: {
|
|
js: getUrl('dist/index.js'),
|
|
css: getUrl('dist/index.css')
|
|
}
|
|
}
|