So, I’m just giving Cloudflare Pages a try and I’m currently stumbling upon this issue that I don’t quite know how to fix.
I have an 11ty website, with SCSS and JS files. CF builds it just fine, but apparently the browser doesn’t quite like what it’s being served:
So is this something I need to take care of? Is there a config of some sort I may be missing?
The classic: solving my own issue as soon as I ask online.
So apparently I was running into a 404, masked as a 304.
I export my assets from CSS and JS into a folder and then ask 11ty to copy it to
static_assets/ — perhaps this could be done in a better way to begin with.
Which means my files didn’t actually exist. And for some reason, the browser was being served an HTML file instead. Hence the wrong MIME type. Makes sense now.
I debugged this by doing multiple
pwd in a npm script and watching the result in CF’s logs.
So the solution for me was adding a new npm script which copies the built CSS and JS files from one folder to
/dist. That’s it.