Javascript compression now caches
This commit is contained in:
parent
0364cca624
commit
67d8e3bec2
1 changed files with 9 additions and 4 deletions
|
@ -24,6 +24,8 @@ var lastPregen = 0
|
||||||
|
|
||||||
var pregenFiles = []
|
var pregenFiles = []
|
||||||
|
|
||||||
|
var javascriptCache = {}
|
||||||
|
|
||||||
var globResult = glob.globSync("**/static/**/*.html", { absolute: true })
|
var globResult = glob.globSync("**/static/**/*.html", { absolute: true })
|
||||||
for (var i = 0; i < globResult.length; i++) {
|
for (var i = 0; i < globResult.length; i++) {
|
||||||
var result = globResult[i]
|
var result = globResult[i]
|
||||||
|
@ -328,10 +330,13 @@ module.exports = {
|
||||||
if (!filePath.includes(".js")) {
|
if (!filePath.includes(".js")) {
|
||||||
data = htmlMinifier.minify(data)
|
data = htmlMinifier.minify(data)
|
||||||
} else {
|
} else {
|
||||||
data = await minify({
|
if (!javascriptCache[filePath]) {
|
||||||
compressor: uglifyJs,
|
javascriptCache[filePath] = await minify({
|
||||||
content: data
|
compressor: uglifyJs,
|
||||||
})
|
content: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
data = javascriptCache[filePath]
|
||||||
}
|
}
|
||||||
|
|
||||||
res.send(data)
|
res.send(data)
|
||||||
|
|
Loading…
Reference in a new issue