fix(types): include CSS entrypoints in PublicPath generation (#2150)
Co-authored-by: Aaron <aaronklinker1@gmail.com>
This commit is contained in:
@@ -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>');
|
||||
|
||||
@@ -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<WxtDirFileEntry> {
|
||||
const defaultLocale = wxt.config.manifest.default_locale;
|
||||
const template = `// Generated by wxt
|
||||
|
||||
Reference in New Issue
Block a user