kajtzu
04/24/2023, 10:16 AMnpx wrangler pages publish build --project-name=
to deploy to CF. Reading the forums it seems that many others have stumbled on the same problem 2021 and 2022 without it getting fixed, it seems. So I added a _headers file which overrides the content-type for /*.js
and /*.css
correctly because modern browsers tend to be picky and they do not want to execute .js files unless the mime type is correctly set. This part works but it is really annoying to have to do that.
While troubleshooting this, I noticed an even curiouser case where if I request /index.html I get the file as one would expect, but if I request /assets/index-424242.js I get, instead of the uploaded javascript, file the contents of the top level index.html instead. This obviously breaks everything.
Now, as I build elsewhere, I can prove (to myself) that vite+swc built everything correctly and that there really is a 4.5 MB assets/index-424242.js file in the build root. If I deploy the static javascript stuff to a regular nginx instance anywhere I get the correct files and that's that.
Recap:
- I build and package outside CF
- I use wrangler to upload
- There aren't any functions, I have assumed pages.dev is simply a place that serves files that were uploaded there
- The entire site consists of html, js, svg, css assets
Any ideas on where to start? Any pointers welcome, of course...Skye
04/24/2023, 11:05 AMkajtzu
04/24/2023, 11:43 AM