Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions packages/wxt/e2e/tests/typescript-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', '<html></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', '<html></html>');
Expand Down
14 changes: 13 additions & 1 deletion packages/wxt/src/core/generate-wxt-dir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function getPathsDeclarationEntry(
getEntrypointBundlePath(
entry,
wxt.config.outDir,
isHtmlEntrypoint(entry) ? '.html' : '.js',
getEntrypointPublicExt(entry),
),
)
.concat(await getPublicFiles());
Expand Down Expand Up @@ -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<WxtDirFileEntry> {
const defaultLocale = wxt.config.manifest.default_locale;
const template = `// Generated by wxt
Expand Down
Loading