diff --git a/build.ts b/build.ts index a44cd90..6dc06ae 100644 --- a/build.ts +++ b/build.ts @@ -35,13 +35,43 @@ const postProcess = (str: string): string => { // Add ADDITIONAL CODE block str = str.replace('var DEFAULT_FLAGS', '\n/* ADDITIONAL CODE */\n\nvar DEFAULT_FLAGS'); - // Minify SVG - str = str.replaceAll(/= "( `', 'e => `'); + + // Simplify object definitions + // {[1]: "a"} => {1: "a"} + str = str.replaceAll(/\[(\d+)\]: /g, '$1: '); + // {["a"]: 1, ["b-c"]: 2} => {a: 1, "b-c": 2} + str = str.replaceAll(/\["([^"]+)"\]: /g, function(match, p1) { + if (p1.includes('-') || p1.match(/^\d/)) { + p1 = `"${p1}"`; + } + + return p1 + ': '; }); - str = str.replaceAll('(e) => `', 'e => `'); + // Minify SVG import code + const svgMap = {} + str = str.replaceAll(/var ([\w_]+) = ("