From 068a14ffa464d6cb0ccc5c3cec11d10d8cceae90 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Sun, 26 Mar 2023 22:39:07 +0530 Subject: Sharing code between scripts for reduced bundle size. --- config/webpack/utils/get-injection-code.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'config/webpack/utils/get-injection-code.js') diff --git a/config/webpack/utils/get-injection-code.js b/config/webpack/utils/get-injection-code.js index 51d1c20..6333a6a 100644 --- a/config/webpack/utils/get-injection-code.js +++ b/config/webpack/utils/get-injection-code.js @@ -1,18 +1,10 @@ module.exports.getInjectionCode = (code, front) => { - const escapeSequences = [ - ["\b", "\\b"], - ["\f", "\\f"], - ["\n", "\\n"], - ["\r", "\\r"], - ["\t", "\\t"], - ["\v", "\\v"] - ]; + const escapeSequences = ["b", "f", "n", "r", "t", "v"]; let finalCode = code.replaceAll("`","\\`"); for (const escapeSequence of escapeSequences) { finalCode = finalCode - .replaceAll(escapeSequence[1], "\\" + escapeSequence[1]) - .replaceAll(escapeSequence[0], escapeSequence[1]); + .replaceAll("\\" + escapeSequence, "\\\\" + escapeSequence) } const concatenationCode = front -- cgit v1.2.3