Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WXT should bundle multiple background.js scripts like it does with content.js #1038

Open
placoderm opened this issue Oct 3, 2024 · 0 comments
Labels

Comments

@placoderm
Copy link

Feature Request

Currently it is easy to modularize the content scripts in the entrypoints folder by simply appending .content.ts to the file name.

Add the same ability to background.js.

Is your feature request related to a bug?

N/A

What are the alternatives?

From @aaronklinker-st :

For now, a quick fix to using multiple background scripts is to use Vite's glob import:

// background/index.ts
const scripts = import.meta.glob<{ default: () => void }>('./*.background.ts', { eager: true });

export default defineBackground(() => {
  Object.values(scripts).map(script => script.default.main());
});

Then put your other files in like background/some-name.background.ts

Additional context

https://discord.com/channels/1212416027611365476/1290896813850886197

@aklinker1 aklinker1 changed the title MXT should bundle multiple background.js scripts like it does with content.js WXT should bundle multiple background.js scripts like it does with content.js Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant