Optimize built scripts

This commit is contained in:
redphx
2024-10-10 21:43:42 +07:00
parent 728abced45
commit 6fa1f73702
3 changed files with 30 additions and 25 deletions

View File

@@ -55,7 +55,7 @@ const postProcess = (str: string): string => {
// Minify SVG import code
const svgMap = {}
str = str.replaceAll(/var ([\w_]+) = ("<svg.*?");\n\n/g, function(match, p1, p2) {
str = str.replaceAll(/var ([\w_]+) = ("<svg.*?");\n\n/g, (match, p1, p2) => {
// Remove new lines in SVG
p2 = p2.replaceAll(/\\n*\s*/g, '');
@@ -82,6 +82,11 @@ const postProcess = (str: string): string => {
// Remove comment line
str = str.replaceAll(/\\n\/\/.*?(?=\\n)/g, '');
// Replace ${"time".toUpperCase()} with "TIME"
str = str.replaceAll(/\$\{"([^"]+)"\.toUpperCase\(\)\}/g, (match, p1) => {
return p1.toUpperCase();
});
assert(str.includes('/* ADDITIONAL CODE */'));
assert(str.includes('window.BX_EXPOSED = BxExposed'));
assert(str.includes('window.BxEvent = BxEvent'));