Netlify won't build Astro dist/content and chunk folders

Yeah, see if that helps you reproduce the issue.

I’ve tested the repo via WSL (using Ubuntu 22.04) and it will generate both folders:

WSL log
 bun run build
$ astro build
14:57:03 [build] output: "static"
14:57:03 [build] directory: /mnt/d/test-bun-netlify/dist/
14:57:03 [build] Collecting build info...
14:57:03 [build] βœ“ Completed in 2.22s.
14:57:04 [build] Building static entrypoints...
14:57:06 [vite] βœ“ built in 2.02s
14:57:06 [build] βœ“ Completed in 2.10s.

 building client (vite) 
14:57:06 [vite] βœ“ 14 modules transformed.
14:57:06 [vite] dist/_astro/Greeting.D7NBPO3f.js         0.71 kB β”‚ gzip: 0.47 kB
14:57:06 [vite] dist/_astro/client.CEGoIkZ3.js           1.84 kB β”‚ gzip: 1.03 kB
14:57:06 [vite] dist/_astro/hooks.module.CDkITd9h.js     2.77 kB β”‚ gzip: 1.23 kB
14:57:06 [vite] dist/_astro/signals.module.Cdp8wEfo.js   6.70 kB β”‚ gzip: 2.49 kB
14:57:06 [vite] dist/_astro/preact.module.CyhH757G.js   10.13 kB β”‚ gzip: 4.25 kB
14:57:06 [vite] βœ“ built in 328ms

 generating static routes 
14:57:07 β–Ά src/pages/about.astro
14:57:07   └─ /about/index.html (+9ms)
14:57:07 β–Ά src/pages/blog.astro
14:57:07   └─ /blog/index.html (+22ms)
14:57:07 β–Ά src/pages/posts/[...slug].astro
14:57:07   β”œβ”€ /posts/post-1/index.html (+78ms)
14:57:07   β”œβ”€ /posts/post-3/index.html (+35ms)
14:57:07   β”œβ”€ /posts/post-2/index.html (+36ms)
14:57:07   └─ /posts/post-4/index.html (+36ms)
14:57:07 Ξ» src/pages/rss.xml.js
14:57:07   └─ /rss.xml14:57:07 [WARN] [router] No API Route handler exists for the method "GET" for the route "/rss.xml".
Found handlers: "get"

 (+1ms)
14:57:07 β–Ά src/pages/tags/[tag].astro
14:57:07   β”œβ”€ /tags/astro/index.html (+10ms)
14:57:07   β”œβ”€ /tags/blogging/index.html (+5ms)
14:57:07   β”œβ”€ /tags/learning in public/index.html (+6ms)
14:57:07   β”œβ”€ /tags/setbacks/index.html (+6ms)
14:57:07   β”œβ”€ /tags/community/index.html (+5ms)
14:57:07   └─ /tags/successes/index.html (+5ms)
14:57:07 β–Ά src/pages/tags/index.astro
14:57:07   └─ /tags/index.html (+5ms)
14:57:07 β–Ά src/pages/index.astro
14:57:07   └─ /index.html (+8ms)
14:57:07 βœ“ Completed in 870ms.

14:57:08 [build] 14 page(s) built in 6.34s
14:57:08 [build] Complete!

I still can’t get that myself, these are my logs:

bun run build
$ astro build
01:17:31 [build] output: "static"
01:17:31 [build] directory: /home/hrishikesh/tickets/f-117044/dist/
01:17:31 [build] Collecting build info...
01:17:31 [build] βœ“ Completed in 448ms.
01:17:31 [build] Building static entrypoints...
01:17:31 [build] Cache invalid, rebuilding from source. Reason: No content manifest was found in the cache.
01:17:31 [vite] βœ“ built in 780ms
01:17:31 [build] βœ“ Completed in 814ms.

 building client (vite) 
01:17:32 [vite] βœ“ 14 modules transformed.
01:17:32 [vite] dist/_astro/Greeting.D7NBPO3f.js         0.71 kB β”‚ gzip: 0.47 kB
01:17:32 [vite] dist/_astro/client.CEGoIkZ3.js           1.84 kB β”‚ gzip: 1.03 kB
01:17:32 [vite] dist/_astro/hooks.module.CDkITd9h.js     2.77 kB β”‚ gzip: 1.23 kB
01:17:32 [vite] dist/_astro/signals.module.Cdp8wEfo.js   6.70 kB β”‚ gzip: 2.49 kB
01:17:32 [vite] dist/_astro/preact.module.CyhH757G.js   10.13 kB β”‚ gzip: 4.25 kB
01:17:32 [vite] βœ“ built in 133ms

 generating static routes 
01:17:32 β–Ά src/pages/about.astro
01:17:32   └─ /about/index.html (+7ms)
01:17:32 β–Ά src/pages/blog.astro
01:17:32   └─ /blog/index.html (+5ms)
01:17:32 β–Ά src/pages/posts/[...slug].astro
01:17:32   β”œβ”€ /posts/post-1/index.html (+6ms)
01:17:32   β”œβ”€ /posts/post-2/index.html (+4ms)
01:17:32   β”œβ”€ /posts/post-3/index.html (+4ms)
01:17:32   └─ /posts/post-4/index.html (+4ms)
01:17:32 Ξ» src/pages/rss.xml.js
01:17:32   └─ /rss.xml01:17:32 [WARN] [router] No API Route handler exists for the method "GET" for the route "/rss.xml".
Found handlers: "get"

 (+1ms)
01:17:32 β–Ά src/pages/tags/[tag].astro
01:17:32   β”œβ”€ /tags/astro/index.html (+3ms)
01:17:32   β”œβ”€ /tags/blogging/index.html (+2ms)
01:17:32   β”œβ”€ /tags/learning in public/index.html (+2ms)
01:17:32   β”œβ”€ /tags/successes/index.html (+2ms)
01:17:32   β”œβ”€ /tags/setbacks/index.html (+2ms)
01:17:32   └─ /tags/community/index.html (+2ms)
01:17:32 β–Ά src/pages/tags/index.astro
01:17:32   └─ /tags/index.html (+2ms)
01:17:32 β–Ά src/pages/index.astro
01:17:32   └─ /index.html (+9ms)
01:17:32 βœ“ Completed in 98ms.

01:17:32 [build] 14 page(s) built in 1.52s
01:17:32 [build] Complete!

This is all the files I get:

image

01:17:31 [build] Cache invalid, rebuilding from source. Reason: No content manifest was found in the cache.

Even after multiple consecutive builds do you get this line?

Interesting, I just ran another build and then I got that folder and now even after deleting .astro and dist, I get those folders. Why didn’t I get those in the first try?

So if I delete the node_modules directory and build again, the folders go missing again. Can you confirm this?

Yes. Cache is stored in astro node_modules and retrieved in subsequent builds. For some reason, on Netlify this won’t work correctly

Had you started with that context, it would have saved us some back-n-forth.

In this case, I think you would have to run the bun run build command twice. Like bun run build && bun run build.

Netlify will cache your node_modules folder but the cache is unique per deploy context, so it’s not a good way to rely on that. Plus, it would be cleared every time you run a clear cache and build or if you don’t build for a month or so.

I’d personally recommend to change your build process in a way that you don’t have to rely on cache to build those files. The files should be built in one go, with or without cache.

Thanks for your assistance. I didn’t figured out while making OP so your help is very appreciated.
I’ll try to play around with build config then. Eventually I’ll open an issue to Astro repo to get these files generated very early on.
Hope it will work for now

Quick follow up: after using bun run build && bun run build I generated content and chunk folders but after returning to bun run build I get this:

10:22:39 AM: 08:22:39 [build] Cache invalid, rebuilding from source. Reason: No content manifest was found in the cache.

and content/chunks are missing again.
Is Netlify caching correctly? (I only retried last commit on production deploy via website)

Could you share a link to the deploy?

sure thing: https://663c87b5d24b9c82ed3fb8a5--test-bun-netlify.netlify.app/

I just checked the cache for that build and the node_modules/.astro folder seems to have the required stuff cached in there:

So looks like the cache worked fine, but not sure why Astro still wasn’t able to use it. This enforces what I mentioned before that Astro should not have to rely on cache, instead it should be able to build those files with or without cache.

You can try creating your own build plugin: Create Build Plugins | Netlify Docs to handle explicitly caching that folder, but looking at the fact that it was cached, I don’t think that would be useful.

1 Like

Alright, I just set a custom cache folder via astro.config.mjs like this:

  cacheDir: './.cache',

and added Cecil cache plugin. Works as intended

Sorry for the trouble. Thanks again for your help :+1:

1 Like