-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Possibly prescriptive, but I'm trying to create a plugin to generate a webmanifest. My working design is to include the webmanifest file in entryPoints, use the plugin to filter on that file-type (.webmanifest, which is actually just a json file), and do the behind the scenes work within the plugin.
I'm thinking rather than hard-coding file-paths into the json source file (which tooling does not connect to the FS), it's better to inject them via the plugin based on some assumed FS structure like:
src/
webmanifest/
icons/
192.png
512.png
app.webmanifest
I've got the basic plugin working to handle the app.webmanifest file.
I think the simplest way is to add those dependencies into esbuild's inputs/outputs so they're processed normally. But I can't figure out how to add the icons to esbuild's inputs as if they were "imported" by app.webmanifest so they get appropriately hashed etc.
I thought maybe including them in OnLoadResult['watchFiles'] or "looking them up" via PluginBuild['resolve'] would cause that to happen, but no.
Note that the outputted result for the manifest file must be a json file, not a javascript file (it "works" if esbuild is allowed to transform the manifest into js, but that isn't suitable because a manifest file is a json file).
Also, I have a different plugin (as a workaround for esbuild not supporting html as an entry-point: #31) that generates an HTML file and injects <link>s and <script>s based on data in the build.metafile, so that data needs to be accurate (so generating a fake manifest.js will create a problem with the html generator plugin).