Generate JS on run instead of load

This commit is contained in:
bingus_violet 2024-06-26 05:09:19 -05:00
parent 352ea02d6d
commit 0e1f6f09b3

View file

@ -36,6 +36,16 @@ for (var i = 0; i < globResult.length; i++) {
})
}
(async function() {
globResult = glob.globSync("**/static/**/*.js", { absolute: true })
for (var i = 0; i < globResult.length; i++) {
javascriptCache[globResult[i]] = await minify({
compressor: uglifyJs,
content: fs.readFileSync(globResult[i]).toString()
})
}
})()
function firstToUpper(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
@ -331,12 +341,6 @@ module.exports = {
if (!filePath.includes(".js")) {
data = htmlMinifier.minify(data)
} else {
if (!javascriptCache[filePath]) {
javascriptCache[filePath] = await minify({
compressor: uglifyJs,
content: data
})
}
data = javascriptCache[filePath]
}