wxt-dev / wxt-dev/wxt

@wxt/unocss usage in content scripts

Open
#1,125 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending-triage
Dominant language
TypeScript
Stars
10.5k
Forks
564
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Hello,

I've seen the new @wxt/unocss is out, thank you very much :)

However, I cannot get it working with the content script either, but it works within the popup as expected.

Could you manage to get it working in the content script as well?

What is the general approach here, for example if I decide to use other frontend frameworks? Will they all break and lack CSS in the content script?

Reproduction

entrypoints/content/index.ts

import "uno.css";
import App from "./App.vue";
import { createApp } from "vue";

export default defineContentScript({
  matches: [URLS],

  runAt: "document_idle",
  cssInjectionMode: "ui",
....

wxt.config.ts

modules: [
"@wxt-dev/module-vue",
"@wxt-dev/unocss"
],

unocss:{
configOrPath:"./unocss.config.ts"
},

manifest: {
host_permissions: [URL_PATTERN],

permissions: [
  "alarms",
  "privacy",
  "cookies",
  "storage",
  "offscreen",
  "scripting",
  "activeTab",
  "webRequest",
  "loginState",
  "geolocation",
  "notifications",
  "nativeMessaging",
  "web_accessible_resources"
]

}


### Steps to reproduce

_No response_

### System Info

```shell
System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 1.18 GB / 15.77 GB
  Binaries:
    Node: 22.9.0 - ~\AppData\Local\Volta\tools\image\node\22.9.0\node.EXE
    Yarn: 4.5.1 - ~\AppData\Local\Volta\tools\image\yarn\4.5.1\bin\yarn.CMD
    npm: 10.8.3 - ~\AppData\Local\Volta\tools\image\node\22.9.0\npm.CMD
  Browsers:
    Chrome: 130.0.6723.70
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    vite: 5.4.10 => 5.4.10 
    wxt: 0.19.13 => 0.19.13
Used Package Manager

yarn

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with entrypoints/content/index.ts and wxt.config.ts, focusing on the uno.css import, @wxt-dev/unocss configuration, and cssInjectionMode: "ui". Compare how styles work in the popup with the content-script path; done means the reproduced content-script UI receives the expected UnoCSS styles.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.