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

Generate PublicPath from web_accessible_resources #1051

Open
1natsu172 opened this issue Oct 6, 2024 · 4 comments
Open

Generate PublicPath from web_accessible_resources #1051

1natsu172 opened this issue Oct 6, 2024 · 4 comments
Labels
Milestone

Comments

@1natsu172
Copy link
Contributor

Feature Request

Question from: https://discord.com/channels/1212416027611365476/1272982191764144248/1274317491337957408

publicPath

Is your feature request related to a bug?

N/A

What are the alternatives?

Add manually custom PublicPaths module.

// modules/add-public-paths.ts
export default defineWxtModule((wxt) => {
  wxt.hooks.hook('prepare:publicPaths', (_, paths) => paths.push('/content-scripts/injected.css'));
})

Additional context

N/A

@1natsu172
Copy link
Contributor Author

1natsu172 commented Oct 6, 2024

We forgot his question, so I made it an Issue for now.

If we want to implement this feature, I can take it.

@aklinker1
Copy link
Collaborator

Two problems with this:

  1. Public paths are generated before the manifest
  2. Resources can have wildcards

Wildcards we wouldn't be able to support, because we'd have to do a build before generating the path to list all the files that match that pattern. The whole point of the wxt prepare command is to NOT build the extension.

And we shouldn't generate the manifest twice, once before the build and once after the build.

Here's the current order of operations:

  1. Resolve config
  2. Load entrypoint options
  3. Generate public path
  4. Build entrypoints
  5. Generate manifest

We might be able to move generating the manifest up, and only writing it to the output folder after the build. That would at least let us add real file paths to public paths from the manifest, as shown in the original discuss message.

Need to think more on this, I'll add this to the 1.0 milestone as a potential breaking change to knock out before that release.

@aklinker1 aklinker1 added this to the v1.0 milestone Oct 6, 2024
@1natsu172
Copy link
Contributor Author

Hmm, Thanks and I have a more understanding. I didn't think that complex case and thought I could just parse the web_accessible_resources config in wxt.config.ts. In reality, it was more complicated…

It would be possible to branch the .wxt generation phase before and after the build, but that might create another complication. Basically, most things should be single-flow and simple to get right.🤔

@aklinker1
Copy link
Collaborator

I didn't think that complex case and thought I could just parse the web_accessible_resources config in wxt.config.ts. In reality, it was more complicated…

Yeah, can't just grab it from there, modules or project hooks might be modifying it. So then you have to also trigger all that, which we should only do once.

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

2 participants