From 7f4996c908967224c6de86dc5630f496a9e49eaa Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sun, 21 Nov 2021 18:34:36 +0100 Subject: [PATCH 1/5] Add fonts copy to rollup config --- package.json | 1 + rollup.config.js | 10 ++++++++++ yarn.lock | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/package.json b/package.json index 3a32a0c..9356814 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "dependencies": { "@rollup/plugin-commonjs": "^21.0.1", "@rollup/plugin-node-resolve": "^13.0.6", + "@rollup/plugin-url": "^6.1.0", "argon2": "^0.28.2", "clear-module": "^4.1.1", "compression": "^1.7.4", diff --git a/rollup.config.js b/rollup.config.js index a3a40b7..f8d3386 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -6,6 +6,7 @@ import commonjs from "@rollup/plugin-commonjs"; import {terser} from "rollup-plugin-terser"; import livereloadRollupPlugin from "rollup-plugin-livereload"; import imageminPlugin from "rollup-plugin-imagemin"; +import url from "@rollup/plugin-url"; const production = process.env.ENV === 'production'; const buildDir = process.env.BUILD_DIR; @@ -41,6 +42,15 @@ export default commandLineArgs => ({ // Extract css into separate files cssOnlyRollupPlugin({output: 'bundle.css'}), + url({ + include: [ + '**/*.woff2?', + '**/*.ttf', + ], + limit: 0, + fileName: path.join('../', 'fonts', '[name][extname]'), + }), + // If you have external dependencies installed from // npm, you'll most likely need these plugins. In // some cases you'll need additional configuration - diff --git a/yarn.lock b/yarn.lock index 246ec5a..2ef37c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -601,6 +601,15 @@ is-module "^1.0.0" resolve "^1.19.0" +"@rollup/plugin-url@^6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-url/-/plugin-url-6.1.0.tgz#1234bba9aa30b5972050bdfcf8fcbb1cb8070465" + integrity sha512-FJNWBnBB7nLzbcaGmu1no+U/LlRR67TtgfRFP+VEKSrWlDTE6n9jMns/N4Q/VL6l4x6kTHQX4HQfwTcldaAfHQ== + dependencies: + "@rollup/pluginutils" "^3.1.0" + make-dir "^3.1.0" + mime "^2.4.6" + "@rollup/pluginutils@4": version "4.1.1" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-4.1.1.tgz#1d4da86dd4eded15656a57d933fda2b9a08d47ec" From 10d5d1696797889ebed6ec0a0281ab63fcee56ff Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sun, 21 Nov 2021 20:17:49 +0100 Subject: [PATCH 2/5] Watch DOM changes to add external link icons to new external links --- src/assets/views/scripts/ExternalLinkIcons.svelte | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/assets/views/scripts/ExternalLinkIcons.svelte b/src/assets/views/scripts/ExternalLinkIcons.svelte index 62f0a81..e21205e 100644 --- a/src/assets/views/scripts/ExternalLinkIcons.svelte +++ b/src/assets/views/scripts/ExternalLinkIcons.svelte @@ -11,6 +11,7 @@ document.querySelectorAll('a[target="_blank"]').forEach(el => { if (!el.classList.contains('no-icon')) { + el.classList.add('no-icon'); el.appendChild(iconElement.cloneNode(true)); } }); @@ -18,6 +19,13 @@ onMount(() => { addExternalLinkIcons(); + + new MutationObserver(() => { + addExternalLinkIcons(); + }).observe(document.body, { + childList: true, + subtree: true, + }); }); From 5cfdecfebf3d1d83d6284c769208a7e1a42f15b5 Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Sun, 21 Nov 2021 20:18:15 +0100 Subject: [PATCH 3/5] Also replace icons afterUpdate --- src/assets/views/utils/Icon.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/assets/views/utils/Icon.svelte b/src/assets/views/utils/Icon.svelte index 5063048..ff5da20 100644 --- a/src/assets/views/utils/Icon.svelte +++ b/src/assets/views/utils/Icon.svelte @@ -1,6 +1,6 @@