Closed joshua1 closed 4 years ago
Is it working at all, even without code splitting?
You need to pass the --single
flag to sirv
, to be able to load your SPA from any URL.
See how it is done at this line for an example.
If you share your project, I'll clone it and have a look.
I don't have any issues with code splitting, even though I used the -D
flag in package.json instead of the routify plugin in rollup.config.js as @joshua1 is saying. (and that way also works for me)
https://github.com/sveltech/routify/issues/29 for a sample repo (last post)
To be clear, what I'm suggesting is to try with a command like this:
npx sirv public --dev --single
Without the --single
flag, sirv will 404 on any page that does not exist (which is essentially every page in the client router). The 404 tells it to send index.html
instead of 404.
@rixo the --single flag
is there . and i am not running yarn start
or npm run start
yet, i am simply running yarn dev
, the only changes i made to the starter template are the ones i have posted up there . Note also that it works out the box without my changing the setup to enable code splitting. @rixo i am referring to the starter template project, not the example module in routify code base itself. You can try with the template.
I just cloned the starter template with npx @sveltech/routify@next init
and configured it for code-splitting. Unfortunately I can't reproduce the error. Yarn and NPM works and so does CLI mode and Rollup.
Any chance you can share your project or show us your filestructure?
Lastly, have you tried hitting Ctrl + F5 (or equivalent) to clear the browser?
@joshua1 What browser are you using? (type="module"
not supported in IE / Edge, AFAIK)
@jakobrosenberg I used the npx @sveltech/routify@next init
command on a new project and moved my src and other files in there , and it worked. removing node_modules and package lock file didnt seem to work for me , found that strange. maybe have this command in the readme as a way to use the starter template
@joshua1 it will be added to the docs, but for the moment the syntax isn't set in stone. I doubt much will change though.
@jakobrosenberg following the instructions here https://routify.now.sh/docs/codesplitting and using the starter template, i am only able to hit 404 (_fallback.svelte) page and cannot get the links to work. I might be doing something wrong i cant say , my rollup.config file is
and index.html is
Can you have a look please. Thanks a lot