diff --git a/programs/develop/webpack/plugin-css/common-style-loaders.ts b/programs/develop/webpack/plugin-css/common-style-loaders.ts index 471c4c2e..4ef33a5d 100644 --- a/programs/develop/webpack/plugin-css/common-style-loaders.ts +++ b/programs/develop/webpack/plugin-css/common-style-loaders.ts @@ -12,50 +12,50 @@ export interface StyleLoaderOptions { loader?: string } -function whereToInsertStyleTag(element: HTMLElement) { - // Function to check if the shadow root exists - const insertElement = () => { - // @ts-expect-error - global reference. - const shadowRoot = window.__EXTENSION_SHADOW_ROOT__ +// function whereToInsertStyleTag(element: HTMLElement) { +// // Function to check if the shadow root exists +// const insertElement = () => { +// // @ts-expect-error - global reference. +// const shadowRoot = window.__EXTENSION_SHADOW_ROOT__ - if (shadowRoot) { - shadowRoot.appendChild(element) +// if (shadowRoot) { +// shadowRoot.appendChild(element) - if (process.env.EXTENSION_ENV === 'development') { - console.log('Element inserted into shadowRoot') - } - } else { - document.head.appendChild(element) - if (process.env.EXTENSION_ENV === 'development') { - console.log('Element inserted into document.head') - } - } - } +// if (process.env.EXTENSION_ENV === 'development') { +// console.log('Element inserted into shadowRoot') +// } +// } else { +// document.head.appendChild(element) +// if (process.env.EXTENSION_ENV === 'development') { +// console.log('Element inserted into document.head') +// } +// } +// } - // If the shadowRoot is already available, insert immediately - // @ts-expect-error - global reference. - if (window.__EXTENSION_SHADOW_ROOT__) { - insertElement() - return - } +// // If the shadowRoot is already available, insert immediately +// // @ts-expect-error - global reference. +// if (window.__EXTENSION_SHADOW_ROOT__) { +// insertElement() +// return +// } - // Use MutationObserver to wait for the shadow root to be available - const observer = new MutationObserver(() => { - // @ts-expect-error - global reference. - if (window.__EXTENSION_SHADOW_ROOT__) { - insertElement() - observer.disconnect() // Stop observing once the shadow root is found - } else { - // Disconnect the observer if the shadow root is not found after 5 seconds - setTimeout(() => { - observer.disconnect() - }, 5000) - } - }) +// // Use MutationObserver to wait for the shadow root to be available +// const observer = new MutationObserver(() => { +// // @ts-expect-error - global reference. +// if (window.__EXTENSION_SHADOW_ROOT__) { +// insertElement() +// observer.disconnect() // Stop observing once the shadow root is found +// } else { +// // Disconnect the observer if the shadow root is not found after 5 seconds +// setTimeout(() => { +// observer.disconnect() +// }, 5000) +// } +// }) - // Observe changes to the `document.body` or `document.head` - observer.observe(document.body, {childList: true, subtree: true}) -} +// // Observe changes to the `document.body` or `document.head` +// observer.observe(document.body, {childList: true, subtree: true}) +// } export async function commonStyleLoaders( projectPath: string, @@ -67,9 +67,9 @@ export async function commonStyleLoaders( ? miniCssLoader : { loader: require.resolve('style-loader'), - options: { - insert: whereToInsertStyleTag - } + // options: { + // insert: whereToInsertStyleTag + // } }, { loader: require.resolve('css-loader'),