feat: Automatically add CSS files to content scripts

This commit is contained in:
Aaron Klinker
2023-06-22 23:23:41 -05:00
parent 53fb805a3b
commit 047ce0464e
+11 -1
View File
@@ -269,6 +269,16 @@ function getContentScriptCssFiles(
contentScripts: ContentScriptEntrypoint[],
buildOutput: BuildOutput,
): string[] | undefined {
console.warn('TODO: getContentScriptCssFiles');
const css: string[] = [];
contentScripts.forEach((script) => {
const cssRegex = new RegExp(`^assets/${script.name}-[a-f0-9]{8}.css$`);
const relatedCss = buildOutput.find((chunk) =>
chunk.fileName.match(cssRegex),
);
if (relatedCss) css.push(relatedCss.fileName);
});
if (css.length > 0) return css;
return undefined;
}