browser-extension icon indicating copy to clipboard operation
browser-extension copied to clipboard

Tailwind in content scripts doesn't work

Open KULTI1995 opened this issue 1 year ago • 3 comments

  1. Does not generate tailwinds in content scripts. Styles don't load at all.
  2. Manifest generation in build.ts does not work, how to solve:
  const fullPath = relative(
    extDir,
    resolve(pageDir, pageFile)
  )

  return fullPath.replace('\\', '/')
  1. Tailwind on different pages will generate different problems when we don't use shadowDom. Therefore styles should be generated as a separate file. Like here:
import { createRoot } from 'react-dom/client';
import Main from './Main';

const container = document.createElement('div')
const rootEl = document.createElement('div')
const styleEl = document.createElement('link')
const shadowDOM = container.attachShadow?.({ mode: 'open' }) || container
styleEl.setAttribute('rel', 'stylesheet')
styleEl.setAttribute('href', chrome.runtime.getURL('contentStyle.css'))
shadowDOM.appendChild(styleEl)

shadowDOM.appendChild(rootEl)
document.body.appendChild(container)

const root = createRoot(container); // createRoot(container!) if you use TypeScript
root.render(<Main/>);
  1. css modules in content scripts do not work.

KULTI1995 avatar Mar 25 '23 07:03 KULTI1995

Thanks, for reporting, it's a problem in content script, we'll fix it in next iteration.

Debdut avatar Apr 22 '23 07:04 Debdut

I have encountered this problem, too. Is there a good solution?

chenyusheng avatar Jun 19 '23 12:06 chenyusheng

I'm running into the same issue, any help on getting Tailwind to work would be great

tluthra avatar Feb 15 '24 22:02 tluthra