From 7140dd3b51c2db110437e71f380c1ab5ee2069ec Mon Sep 17 00:00:00 2001 From: OrigamingWasTaken <74014262+OrigamingWasTaken@users.noreply.github.com> Date: Thu, 24 Oct 2024 01:08:17 +0200 Subject: [PATCH] Experimental svelte config --- frontend/svelte.config.js | 49 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/frontend/svelte.config.js b/frontend/svelte.config.js index ed327ff..f838a15 100644 --- a/frontend/svelte.config.js +++ b/frontend/svelte.config.js @@ -1,4 +1,51 @@ -import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; +// import path from "node:path"; +import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; + +// function addComponentIdPreprocessor() { +// return { +// markup: ({ content, filename }) => { +// // Get the component name from the filename +// const componentName = path.basename(filename, '.svelte').toLowerCase(); + +// // Skip processing if the file contains svelte:options +// if (content.includes(']*?(?:>|\s)/; +// const match = content.match(regex); + +// if (match) { +// const originalTag = match[0]; +// const tagEnd = originalTag.endsWith('>') ? '>' : ' '; + +// // Check if the tag already has an id attribute +// if (!originalTag.includes('id=')) { +// // Handle cases where the tag might have other attributes +// let newTag; +// if (originalTag.includes(' ')) { +// // If there are other attributes, insert ID before them +// newTag = originalTag.replace(/^<([^\s>]+)/, `<$1 id="${componentName}"`); +// } else { +// // If it's a simple tag, add the ID +// newTag = originalTag.replace(/>$/, ` id="${componentName}">`); +// } + +// console.log('Original:', originalTag); +// console.log('Modified:', newTag); + +// return { +// code: content.replace(originalTag, newTag) +// }; +// } +// } + +// return { code: content }; +// } +// }; +// } export default { preprocess: [vitePreprocess()],