I tried to generate a static web site with nuxt, but when i open the index.html file, it show an infinite load screen with this JS error :
fail to load element whose source is « file:///_nuxt/42185af33c638e7022a3.js ».
so, after i have search, i change router.base configuration by ./ and it throw this error :
This page could not be found
Back to the home page
but when i click on Back to the home page it showing my home page.
Anyone have an idea how to open index.html file from static build ?
i explain my project : i wish to run my app with Capacitor so i need static build work fine.
Thank by advance and my apologies for my bad english write.
I found two solution:
Solution 1 : Make your project to "universal" instead "single page app"
When you generate a static web app, it work fine when you run index.html. However, Capacitor display the page but don't recognize the router, so you can't switch page in your app.
Solution 2 : Set router in nuxt.config.js in spa
Add this configuration to nuxt.config.js :
router: {
base: './'
mode: 'hash'
}
it work when you open the index.html file in dist, but does not work with capacitor.
My request is therefore partially resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With