From 078fd5990ea32fcd29d42e76569b1de56c4ab9f0 Mon Sep 17 00:00:00 2001 From: Tam Dang <139360620+dahomita@users.noreply.github.com> Date: Sun, 22 Feb 2026 10:00:58 -0500 Subject: [PATCH] fix(types): include CSS entrypoints in PublicPath generation (#2150) Co-authored-by: Aaron --- .../wxt/e2e/tests/typescript-project.test.ts | 23 +++++++++++++++++++ packages/wxt/src/core/generate-wxt-dir.ts | 14 ++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/wxt/e2e/tests/typescript-project.test.ts b/packages/wxt/e2e/tests/typescript-project.test.ts index 35d35a6a..663c5d28 100644 --- a/packages/wxt/e2e/tests/typescript-project.test.ts +++ b/packages/wxt/e2e/tests/typescript-project.test.ts @@ -63,6 +63,29 @@ describe('TypeScript Project', () => { `); }); + it('should include CSS entrypoints in browser.runtime.getURL paths', async () => { + const project = new TestProject(); + project.addFile('entrypoints/unlisted.html', ''); + project.addFile( + 'entrypoints/plain.css', + `body { + color: red; + }`, + ); + project.addFile( + 'entrypoints/overlay.content.css', + `body { + color: blue; + }`, + ); + + await project.prepare(); + + const output = await project.serializeFile('.wxt/types/paths.d.ts'); + expect(output).toContain('| "/plain.css"'); + expect(output).toContain('| "/content-scripts/overlay.css"'); + }); + it('should augment the types for browser.i18n.getMessage', async () => { const project = new TestProject(); project.addFile('entrypoints/unlisted.html', ''); diff --git a/packages/wxt/src/core/generate-wxt-dir.ts b/packages/wxt/src/core/generate-wxt-dir.ts index c0d00381..6832c744 100644 --- a/packages/wxt/src/core/generate-wxt-dir.ts +++ b/packages/wxt/src/core/generate-wxt-dir.ts @@ -70,7 +70,7 @@ async function getPathsDeclarationEntry( getEntrypointBundlePath( entry, wxt.config.outDir, - isHtmlEntrypoint(entry) ? '.html' : '.js', + getEntrypointPublicExt(entry), ), ) .concat(await getPublicFiles()); @@ -107,6 +107,18 @@ declare module "wxt/browser" { }; } +function getEntrypointPublicExt(entry: Entrypoint): '.html' | '.js' | '.css' { + if (isHtmlEntrypoint(entry)) return '.html'; + + switch (entry.type) { + case 'content-script-style': + case 'unlisted-style': + return '.css'; + default: + return '.js'; + } +} + async function getI18nDeclarationEntry(): Promise { const defaultLocale = wxt.config.manifest.default_locale; const template = `// Generated by wxt