From c3a78c6f11a4a489f0eb0d6b6a88a8535a168386 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Fri, 12 Apr 2024 01:09:33 +0200 Subject: refactor(frontend): improve SVG minification --- .../docs/src/learn/tutorials/file-system/fig1.svg | 52 ++++++------ .../docs/src/learn/tutorials/file-system/fig2.svg | 96 +++++++++++----------- .../docs/src/learn/tutorials/file-system/fig3.svg | 90 ++++++++++---------- .../docs/src/learn/tutorials/file-system/fig4.svg | 86 +++++++++---------- subprojects/docs/src/plugins/loadersPlugin.ts | 20 ++++- .../frontend/src/graph/export/exportDiagram.tsx | 2 +- 6 files changed, 180 insertions(+), 166 deletions(-) (limited to 'subprojects') diff --git a/subprojects/docs/src/learn/tutorials/file-system/fig1.svg b/subprojects/docs/src/learn/tutorials/file-system/fig1.svg index f39a43fe..1e20393a 100644 --- a/subprojects/docs/src/learn/tutorials/file-system/fig1.svg +++ b/subprojects/docs/src/learn/tutorials/file-system/fig1.svg @@ -1,72 +1,72 @@ - + - + - - + + FileSystem::new - -FileSystem + +FileSystem - + - + - - + + File::new - -File + +File - + - + root - + - - + + Dir::new - -File + +File - -Dir + +Dir - + - + root - + element - + element - \ No newline at end of file + diff --git a/subprojects/docs/src/learn/tutorials/file-system/fig2.svg b/subprojects/docs/src/learn/tutorials/file-system/fig2.svg index f7e85fd5..6375bfd6 100644 --- a/subprojects/docs/src/learn/tutorials/file-system/fig2.svg +++ b/subprojects/docs/src/learn/tutorials/file-system/fig2.svg @@ -1,54 +1,54 @@ - + - + - - + + FileSystem::new - -FileSystem + +FileSystem - + - + - - + + File::new - -File + +File - + - + root - + - - + + Dir::new - -File + +File - -Dir + +Dir - + - + @@ -56,34 +56,34 @@ - + element - + - - + + resources - -File + +File - -Dir + +Dir - + - + element - + @@ -91,7 +91,7 @@ - + @@ -99,47 +99,47 @@ element - + element - + - - + + img - -File + +File - -Dir + +Dir - + - + element - + element - + element - \ No newline at end of file + diff --git a/subprojects/docs/src/learn/tutorials/file-system/fig3.svg b/subprojects/docs/src/learn/tutorials/file-system/fig3.svg index 4137e035..0d020a71 100644 --- a/subprojects/docs/src/learn/tutorials/file-system/fig3.svg +++ b/subprojects/docs/src/learn/tutorials/file-system/fig3.svg @@ -1,85 +1,85 @@ - + - + - - + + FileSystem::new - -FileSystem -exists + +FileSystem +exists - + - + - - + + File::new - -File -exists + +File +exists - + - + equals - + - - + + Dir::new - -File -exists + +File +exists - + -Dir +Dir - + equals - + - - + + resources - -File -exists + +File +exists - + -Dir +Dir - + @@ -88,37 +88,37 @@ - + equals - + - - + + img - -File -exists + +File +exists - + -Dir +Dir - + equals - \ No newline at end of file + diff --git a/subprojects/docs/src/learn/tutorials/file-system/fig4.svg b/subprojects/docs/src/learn/tutorials/file-system/fig4.svg index 704f9404..d6701bdd 100644 --- a/subprojects/docs/src/learn/tutorials/file-system/fig4.svg +++ b/subprojects/docs/src/learn/tutorials/file-system/fig4.svg @@ -1,45 +1,45 @@ - + - + - - + + FileSystem::new - -FileSystem + +FileSystem - + - + - - + + File::new - -File + +File - + - + - - + + Dir::new - -File + +File - + -Dir +Dir - + @@ -49,29 +49,29 @@ - + - - + + resources - -File + +File - + -Dir +Dir - + root - + @@ -79,40 +79,40 @@ - + element - + - - + + img - -File -invalidContainer + +File +invalidContainer - + - + root - + element - + @@ -121,11 +121,11 @@ - + element - \ No newline at end of file + diff --git a/subprojects/docs/src/plugins/loadersPlugin.ts b/subprojects/docs/src/plugins/loadersPlugin.ts index 28474511..325d7f67 100644 --- a/subprojects/docs/src/plugins/loadersPlugin.ts +++ b/subprojects/docs/src/plugins/loadersPlugin.ts @@ -50,9 +50,23 @@ export default function loadersPlugin(): Plugin { } loader.options = { ...(typeof loader.options === 'object' ? loader.options : {}), - // Disable SVGO, because it interferes styling figures exported from Refinery with CSS. - svgo: false, - svgoConfig: undefined, + svgo: true, + svgoConfig: { + plugins: [ + { + name: 'preset-default', + params: { + overrides: { + removeTitle: false, + removeViewBox: false, + // Disable SVGO, because it interferes styling figures exported from Refinery with CSS. + inlineStyles: false, + cleanupIds: false, + }, + }, + }, + ], + }, }; svgoDisabled = true; }); diff --git a/subprojects/frontend/src/graph/export/exportDiagram.tsx b/subprojects/frontend/src/graph/export/exportDiagram.tsx index a0c3460c..52d19aa0 100644 --- a/subprojects/frontend/src/graph/export/exportDiagram.tsx +++ b/subprojects/frontend/src/graph/export/exportDiagram.tsx @@ -63,7 +63,7 @@ function fixIDs(id: string, svgDocument: XMLDocument) { idMap.set(`url(#${oldId})`, `url(#${newId})`); node.setAttribute('id', newId); } else { - node.setAttribute('id', ''); + node.removeAttribute('id'); } }); svgDocument.querySelectorAll('[clip-path]').forEach((node) => { -- cgit v1.2.3-54-g00ecf