Merge pull request #225 from sharelatex/ho-hash-on-minifiy-only

only hash the static content when minified is on
This commit is contained in:
James Allen 2017-12-19 15:00:15 +00:00 committed by GitHub
commit 0a4febfce6

View file

@ -36,7 +36,6 @@ getFileContent = (filePath)->
logger.log filePath:filePath, "file does not exist for hashing" logger.log filePath:filePath, "file does not exist for hashing"
return "" return ""
logger.log "Generating file hashes..."
pathList = [ pathList = [
"#{jsPath}libs/require.js" "#{jsPath}libs/require.js"
"#{jsPath}ide.js" "#{jsPath}ide.js"
@ -46,6 +45,10 @@ pathList = [
"/stylesheets/ol-style.css" "/stylesheets/ol-style.css"
] ]
if !Settings.useMinifiedJs
logger.log "not using minified JS, not hashing static files"
else
logger.log "Generating file hashes..."
for path in pathList for path in pathList
content = getFileContent(path) content = getFileContent(path)
hash = crypto.createHash("md5").update(content).digest("hex") hash = crypto.createHash("md5").update(content).digest("hex")
@ -121,7 +124,7 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
res.locals.buildJsPath = (jsFile, opts = {})-> res.locals.buildJsPath = (jsFile, opts = {})->
path = Path.join(jsPath, jsFile) path = Path.join(jsPath, jsFile)
if opts.hashedPath if opts.hashedPath && hashedFiles[path]?
path = hashedFiles[path] path = hashedFiles[path]
if !opts.qs? if !opts.qs?
@ -141,7 +144,7 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
res.locals.buildCssPath = (cssFile, opts)-> res.locals.buildCssPath = (cssFile, opts)->
path = Path.join("/stylesheets/", cssFile) path = Path.join("/stylesheets/", cssFile)
if opts?.hashedPath if opts?.hashedPath && hashedFiles[path]?
hashedPath = hashedFiles[path] hashedPath = hashedFiles[path]
return Url.resolve(staticFilesBase, hashedPath) return Url.resolve(staticFilesBase, hashedPath)
return Url.resolve(staticFilesBase, path) return Url.resolve(staticFilesBase, path)