Files stored in public are not all available

I have been trying to work this out for a long time and see all the threads asking similar questions are unanswered so I’ll give it a shot asking myself.

When meteor builds, then I deploy it on my server, only some images in the public folder are available. Is this related to how they are referenced in the html files themselves? The ones referenced in html files show up just fine but the ones not referenced anywhere are not available. And they all show up on my local dev env.

Such as the file in my public directory: site.webmanifest references files sitting in the same public directory but they are not able to be seen but the file itself is.

How can this be? Where is this explained in more detail?

I know deploying meteor is one of the only really hard parts of meteor, I really wish it was documented/detailed more for self deploying without galaxy or another helper.

Can you give an example of the contents of the public folder and how you reference them resulting to the error?

Here is an example of something that works:

<img src="/images/guy-1.png" class="img-fluid" alt="1 guy">

Here are two examples of something that doesn’t work:

  <link rel="apple-touch-icon" sizes="180x180" href="https://website.com/images/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">

(trying both ways to reference to see if anything would work)

the images are both in public/images. I can’t even manually load the favicon images if I type the url into the browser, or any method. These are both in html files, one is obviously the head, the other is just a random page.

Have a look at Meteor-up it makes deployment really easy.

I don’t know the exact details, but presumably the unused assets in /public are not put in the bundle. You would probably want this behaviour, as it will reduce the bundle size. If you really want to make sure they go up, you can create a page that references them, even if that page never gets displayed.

The intention is not to not learn how it works and use mup bit instead have a more clear understanding how a very critical part of the build phase occurs.

I was able to make it work by adjusting nginx to point to the nested directories but I am still unable to get anyone that seemingly knows in depth how the build stage works.

Everything saved under /public is included in the bundle as is whether you reference them or not in your code.

1 Like

@rjdavid do you know where on the meteor github account I can see what runs when I build?

Meteor creates a manifest with a list of all files that is served over HTTP, including the files from public: https://github.com/meteor/meteor/blob/5ea682449ef27993f356bf79fc602f75383f874e/tools/isobuild/bundler.js#L61-L75

At the beginning of the build process this function runs to find all files in public: https://github.com/meteor/meteor/blob/5ea682449ef27993f356bf79fc602f75383f874e/tools/isobuild/package-source.js#L1371

This function runs close to the end of the build process and creates the manifest: https://github.com/meteor/meteor/blob/5ea682449ef27993f356bf79fc602f75383f874e/tools/isobuild/bundler.js#L1642

You can find the manifest from the app run in development at .meteor\local\build\programs\web.browser\program.json. I would start by comparing it with the one created when deploying to make sure they both have the missing public files. If they both have the missing files, the problem might be in the server code instead of Meteor’s build process.

1 Like