Reputation: 55
I was looking for a fix to "refresh doesn't work on components" issue. I found that it works by adding -s in package.json as mentioned here https://github.com/EmilTholin/svelte-routing/issues/32#issuecomment-495923463.
BUT when I deployed my app, I found that it does NOT work in the production build. Any idea why so?
I just want that my Svelte SPA pages do refresh when I do it.
Upvotes: 0
Views: 2895
Reputation: 26
I know this is old, but I was looking to solve this as well. I fixed it by creating a 404.html in netlify and adding it to production build in public folder. Then I added these scripts:
"start": "sirv public -s", "start:dev": "sirv public --dev -s"
to package.json. Works for me.
Upvotes: 0
Reputation: 55
I found that by creating a 200.html file (which basically has same content as index.html), it all works. Add that file to your production build folder.
As mentioned by @rixo as well, it is not documented (just 404.html, they must have added 200.html recently), but that's how you tell gh pages to send the index to any request for an unknown page.
Upvotes: 2
Reputation: 25001
You need to do essentially the same thing for your prod setup. Your server needs to serve the index.html for any URL, instead of 404, with SPAs, to let the client-side router take over.
How you do this entirely depends on your prod dev server. You have middlewares for express and the like, and generally standalone web servers have an option for that, often called fallback
or single
or something like this...
How are you serving your application in prod?
Upvotes: 1