From 442f813bb73df05a7c43c53cbdffadc00cbba969 Mon Sep 17 00:00:00 2001 From: Lapo Luchini Date: Thu, 30 Oct 2025 18:14:37 +0000 Subject: [PATCH] Avoid Base64, only encode the minimum characters. (basic URL encoding would be fine too) --- vite.config.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vite.config.js b/vite.config.js index cfef56e..1ab5283 100644 --- a/vite.config.js +++ b/vite.config.js @@ -16,6 +16,12 @@ const preventSVGEmit = () => { }; }; +function massageSVG(str) { + return str.replace(/["<>#]/g, (c) => { + return '%' + c.charCodeAt(0).toString(16).toUpperCase().padStart(2, '0'); + }); +} + export default defineConfig({ plugins: [ preventSVGEmit(), @@ -25,7 +31,7 @@ export default defineConfig({ if (removeNodes.includes(node.attribs.id)) DomUtils.removeElement(node); else if (node.name == 'link' && node.attribs.rel == 'icon') - node.attribs.href = 'data:image/svg+xml;base64,' + btoa(fs.readFileSync('favicon.svg', 'ascii').replace(/^([^<]+|<[^s]|