mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
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:
commit
0a4febfce6
1 changed files with 19 additions and 16 deletions
|
@ -36,7 +36,6 @@ getFileContent = (filePath)->
|
|||
logger.log filePath:filePath, "file does not exist for hashing"
|
||||
return ""
|
||||
|
||||
logger.log "Generating file hashes..."
|
||||
pathList = [
|
||||
"#{jsPath}libs/require.js"
|
||||
"#{jsPath}ide.js"
|
||||
|
@ -46,6 +45,10 @@ pathList = [
|
|||
"/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
|
||||
content = getFileContent(path)
|
||||
hash = crypto.createHash("md5").update(content).digest("hex")
|
||||
|
@ -121,7 +124,7 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
|||
res.locals.buildJsPath = (jsFile, opts = {})->
|
||||
path = Path.join(jsPath, jsFile)
|
||||
|
||||
if opts.hashedPath
|
||||
if opts.hashedPath && hashedFiles[path]?
|
||||
path = hashedFiles[path]
|
||||
|
||||
if !opts.qs?
|
||||
|
@ -141,7 +144,7 @@ module.exports = (app, webRouter, privateApiRouter, publicApiRouter)->
|
|||
|
||||
res.locals.buildCssPath = (cssFile, opts)->
|
||||
path = Path.join("/stylesheets/", cssFile)
|
||||
if opts?.hashedPath
|
||||
if opts?.hashedPath && hashedFiles[path]?
|
||||
hashedPath = hashedFiles[path]
|
||||
return Url.resolve(staticFilesBase, hashedPath)
|
||||
return Url.resolve(staticFilesBase, path)
|
||||
|
|
Loading…
Reference in a new issue