Open breadgrocery opened 1 month ago
const entrypoints = { common: ["background", "options", "popup"], chrome: ["offscreen"], firefox: [] }; export default defineWxtModule(wxt => { const { browser } = wxt.config; const filterEntrypoints = [...entrypoints.common, ...entrypoints[browser]].filter(Boolean); wxt.config.filterEntrypoints = new Set(filterEntrypoints); });
Interesting, I guess that's works... But it's not the intentional way of filtering entrypoints. Use include
/exclude
in your entrypoints instead, then you don't have to list everything. Those fields are what generates wxt.config.filterEntrypoints
.
https://wxt.dev/guide/essentials/target-different-browsers.html#filtering-entrypoints
Regardless, I can add this hook, would definitely be useful!
Thanks for the tip. I am not familiar with how to define the attributes of entrypoints of type html. This works for me.
<meta name="manifest.include" content="['chrome']" />
Regardless, I can add this hook, would definitely be useful!
Yeah. Coding offers more flexibility than configuration.
Feature Request
Is your feature request related to a bug?
The current configuration property
filterEntrypoints
lacks flexibility. It requires explicitly listing all entrypoints that need to be built, which becomes cumbersome when you only need to exclude specific entrypoints in certain scenarios.For example, I want to exclude the offscreen entrypoint when the browser is firefox. The only solution I've found is as follows. Other approaches either fail to retrieve all entrypoint names for exclusion or fail to configure.
The
skipped
andexclude
properties in Entrypoint have no effect because the filtering logic is applied before theentrypoints:resolved
hook is triggered.What are the alternatives?
Introduce an
entrypoints:beforeResolve
hook.Although, modifications to the
HookResult
returns void or Promiseskipped
orexclude
properties can achieve the goal.