Skip to content

Commit 047ce04

Browse files
committed
feat: Automatically add CSS files to content scripts
1 parent 53fb805 commit 047ce04

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/utils/manifest.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ function getContentScriptCssFiles(
269269
contentScripts: ContentScriptEntrypoint[],
270270
buildOutput: BuildOutput,
271271
): string[] | undefined {
272-
console.warn('TODO: getContentScriptCssFiles');
272+
const css: string[] = [];
273+
274+
contentScripts.forEach((script) => {
275+
const cssRegex = new RegExp(`^assets/${script.name}-[a-f0-9]{8}.css$`);
276+
const relatedCss = buildOutput.find((chunk) =>
277+
chunk.fileName.match(cssRegex),
278+
);
279+
if (relatedCss) css.push(relatedCss.fileName);
280+
});
281+
282+
if (css.length > 0) return css;
273283
return undefined;
274284
}

0 commit comments

Comments
 (0)