Generate JS on run instead of load
This commit is contained in:
parent
352ea02d6d
commit
0e1f6f09b3
1 changed files with 16 additions and 12 deletions
|
@ -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) {
|
function firstToUpper(str) {
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1)
|
return str.charAt(0).toUpperCase() + str.slice(1)
|
||||||
}
|
}
|
||||||
|
@ -331,12 +341,6 @@ module.exports = {
|
||||||
if (!filePath.includes(".js")) {
|
if (!filePath.includes(".js")) {
|
||||||
data = htmlMinifier.minify(data)
|
data = htmlMinifier.minify(data)
|
||||||
} else {
|
} else {
|
||||||
if (!javascriptCache[filePath]) {
|
|
||||||
javascriptCache[filePath] = await minify({
|
|
||||||
compressor: uglifyJs,
|
|
||||||
content: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
data = javascriptCache[filePath]
|
data = javascriptCache[filePath]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue